Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arkworks integration and ed25519 upgrade #496

Merged
merged 59 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
90fce7a
More ArkWorks stuff
annenkov Nov 29, 2023
01bacb6
Upgrade dalek to V2.
abizjak Dec 4, 2023
6e5a653
Done with ArkWorks integration
annenkov Dec 5, 2023
3a3c3c4
Remove pairing; replace it with arkworks bls implementation
annenkov Dec 11, 2023
0087d2c
Merge branch 'upgrade-dalek' into arkworks-integration
annenkov Dec 11, 2023
f2b6a47
Update keygen/derivation and benches to use ArkWorks BLS
annenkov Dec 12, 2023
1b8f8b2
Remove Display from Field constraints; custom display for Fr
annenkov Dec 12, 2023
7683307
Fixes in serialisation
annenkov Dec 13, 2023
872f53f
Fix BLS Fr serialisation; add tests for the arkworks BLS implementation
annenkov Dec 28, 2023
7e56b55
Update the rest of the code to work with v2 of de25519-dalek; remove …
annenkov Jan 2, 2024
0f8cd53
Merge branch 'main' into arkworks-integration
annenkov Jan 3, 2024
5cd91fc
Use Scalar::from_bits() even though it is depricated; bump ed25519 ve…
annenkov Jan 4, 2024
60cc852
Update changelog
annenkov Jan 4, 2024
a24a923
Cleanup and documentation
annenkov Jan 4, 2024
2a78f20
Formatting
annenkov Jan 4, 2024
d7f1863
More formatting
annenkov Jan 5, 2024
c0d9334
More formatting
annenkov Jan 5, 2024
03beffb
Fixes after clippy
annenkov Jan 5, 2024
21e8f9c
More clippy
annenkov Jan 5, 2024
9fdc813
Remove println statements; supress deprecation warning for from_bits(…
annenkov Jan 8, 2024
c05f4ec
Fix signatures of ed25519 sign functions on the Haskell side
annenkov Jan 8, 2024
a063936
Remove redundant imports in ffi
annenkov Jan 8, 2024
3988bfa
Fix benchmark
annenkov Jan 8, 2024
55606a8
Rust formatting
annenkov Jan 8, 2024
9448367
Update Cargo.lock
annenkov Jan 9, 2024
fb021ea
Merge branch 'main' into arkworks-integration
annenkov Jan 9, 2024
8b6dc46
Remove the use of from_bits.
abizjak Jan 10, 2024
80c2363
Merge remote-tracking branch 'origin/from-bits-shenanigans' into arkw…
annenkov Jan 10, 2024
5e22e5c
Fix links to the VRF RFC
annenkov Jan 10, 2024
023a9f9
Fixes after review: use ArCurve and IpPairing to avoid dependency on …
annenkov Jan 11, 2024
db989f6
Update changelog
annenkov Jan 11, 2024
d451d66
Rename ArCurveG1 into BlsG2
annenkov Jan 11, 2024
351309a
Remove sha2 v0.9
annenkov Jan 11, 2024
6031cc5
Apply suggestions from code review
annenkov Jan 11, 2024
d119977
Merge branch 'arkworks-integration' of github.com:Concordium/concordi…
annenkov Jan 11, 2024
68f32d6
Remove ark dependency from keygen-bls; use reexported types from conc…
annenkov Jan 11, 2024
e1d61c4
Remove debug prints
annenkov Jan 11, 2024
b9d648e
Formatting; derive FromStr for ArkField
annenkov Jan 11, 2024
7fdf2e0
Make scalar_from_bytes work properly for any curve
annenkov Jan 11, 2024
bb8dd04
Fixed comments and cleanup related to affine representation
annenkov Jan 12, 2024
0ac15e0
Update field adapter documentation
annenkov Jan 12, 2024
cc8e78e
Fixes after review: update ArkCurveConfig; improve error reporting in…
annenkov Jan 12, 2024
b3f02d7
Remove Curve::bytes_to_curve_unchecked() corresponding implementation…
annenkov Jan 12, 2024
778d9f3
Add hash-to-curve tests from the previous implementation
annenkov Jan 15, 2024
d662cd5
hash_to_curve returns Result
annenkov Jan 15, 2024
627de2c
Formatting
annenkov Jan 15, 2024
15ccdf1
Apply suggestions from code review
annenkov Jan 15, 2024
a3fdb7a
Remove todo; fix formatting in comments
annenkov Jan 15, 2024
a3f83ea
Resolved comments after review
annenkov Jan 15, 2024
482bbbc
formatting
annenkov Jan 15, 2024
4c92b91
Move hash-to-curve to a separate module; document discrepancies betwe…
annenkov Jan 15, 2024
0566603
Merge branch 'main' into arkworks-integration
annenkov Jan 15, 2024
383fb5d
Cleanup
annenkov Jan 17, 2024
c8fb2fc
Fix scalar_from_bytes: ensure that there is always right number of li…
annenkov Jan 17, 2024
e98c19e
Clippy
annenkov Jan 17, 2024
0d59c2e
Fix scalar_from_bytes: number of chunks was computed wrong
annenkov Jan 17, 2024
cf3768f
Fix total_size_in_bits in scalar_from_bytes: now it's calculated from…
annenkov Jan 18, 2024
658aca4
Clarify behaviour of scalar_from_bytes for short and long input
annenkov Jan 18, 2024
0ef0868
Update rust-src/concordium_base/src/curve_arithmetic/bls12_381_arkwor…
annenkov Jan 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Code should be formatted using [`fourmolu`](https://github.com/fourmolu/fourmolu
version `0.13.1.0` and using the config `fourmolu.yaml` found in the project root.
The CI is setup to ensure the code follows this style.

To check the formatting locally run the following commnad from the project root:
To check the formatting locally run the following command from the project root:


**On unix-like systems**:
Expand Down
2 changes: 1 addition & 1 deletion haskell-src/Concordium/Crypto/BlockSignature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ signatureLength :: Int
signatureLength = Ed25519.signatureSize

sign :: KeyPair -> ByteString -> Signature
sign KeyPair{..} = Signature . Ed25519.sign signKey verifyKey
sign KeyPair{..} = Signature . Ed25519.sign signKey

verify :: VerifyKey -> ByteString -> Signature -> Bool
verify vfKey bs (Signature s) = Ed25519.verify vfKey bs s
Expand Down
17 changes: 8 additions & 9 deletions haskell-src/Concordium/Crypto/Ed25519Signature.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import System.IO.Unsafe

foreign import ccall unsafe "eddsa_priv_key" genPrivateKey :: IO (Ptr SignKey)
foreign import ccall unsafe "eddsa_pub_key" derivePublicFFI :: Ptr SignKey -> IO (Ptr VerifyKey)
foreign import ccall unsafe "eddsa_sign" signFFI :: Ptr Word8 -> Word32 -> Ptr SignKey -> Ptr VerifyKey -> Ptr Word8 -> IO ()
foreign import ccall unsafe "eddsa_sign" signFFI :: Ptr Word8 -> Word32 -> Ptr SignKey -> Ptr Word8 -> IO ()
foreign import ccall unsafe "eddsa_verify" verifyFFI :: Ptr Word8 -> Word32 -> Ptr VerifyKey -> Ptr Word8 -> CSize -> IO Int32
foreign import ccall unsafe "&eddsa_public_free" freeVerifyKey :: FunPtr (Ptr VerifyKey -> IO ())
foreign import ccall unsafe "eddsa_public_to_bytes" toBytesVerifyKey :: Ptr VerifyKey -> Ptr CSize -> IO (Ptr Word8)
Expand Down Expand Up @@ -122,15 +122,14 @@ newKeyPair = do
let verifyKey = deriveVerifyKey signKey
return (signKey, verifyKey)

sign :: SignKey -> VerifyKey -> ByteString -> BSS.ShortByteString
sign signKey verifyKey m = unsafePerformIO $
sign :: SignKey -> ByteString -> BSS.ShortByteString
sign signKey m = unsafePerformIO $
withSignKey signKey $ \signKeyPtr ->
withVerifyKey verifyKey $ \verifyKeyPtr ->
BS.unsafeUseAsCStringLen m $ \(m', mlen) -> do
-- this use of unsafe is fine because the sign function
-- checks the length before dereferencing the data pointer
((), s) <- withAllocatedShortByteString signatureSize $ signFFI (castPtr m') (fromIntegral mlen) signKeyPtr verifyKeyPtr
return s
BS.unsafeUseAsCStringLen m $ \(m', mlen) -> do
-- this use of unsafe is fine because the sign function
-- checks the length before dereferencing the data pointer
((), s) <- withAllocatedShortByteString signatureSize $ signFFI (castPtr m') (fromIntegral mlen) signKeyPtr
return s

verify :: VerifyKey -> ByteString -> BSS.ShortByteString -> Bool
verify vf m sig = (BSS.length sig == signatureSize) && (suc > 0)
Expand Down
2 changes: 1 addition & 1 deletion haskell-src/Concordium/Crypto/SignatureScheme.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ toScheme n
| otherwise = Nothing

sign :: KeyPair -> ByteString -> Signature
sign KeyPairEd25519{..} = Signature . Ed25519.sign signKey verifyKey
sign KeyPairEd25519{..} = Signature . Ed25519.sign signKey

verify :: VerifyKey -> ByteString -> Signature -> Bool
verify (VerifyKeyEd25519 vfKey) bs (Signature s) = Ed25519.verify vfKey bs s
Expand Down
Loading
Loading