Skip to content

Commit

Permalink
fix(libauk-swift): Secp256k1 wrapper does not verify input lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
ppupha committed Mar 11, 2024
1 parent 4c93348 commit 4412a7a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/LibAuk/Utils/secp256k1/Secp256k1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ extension Secp256k1.Signing {
let privkey = data.withUnsafeBytes({ keyBytesPtr in Array(keyBytesPtr) })

// Verify the context and keys are setup correctly
guard secp256k1_context_randomize(context, privkey) == 1,
guard privkey.count == 32,
secp256k1_context_randomize(context, privkey) == 1,
secp256k1_ec_pubkey_create(context, &cPubkey, privkey) == 1,
secp256k1_ec_pubkey_serialize(context, &pubkey, &pubkeyLen, &cPubkey, UInt32(SECP256K1_EC_COMPRESSED)) == 1 else {
self.privateKeyBytes = privatekey
Expand Down

0 comments on commit 4412a7a

Please sign in to comment.