This commit is contained in:
Gruruya 2023-04-03 22:43:37 -04:00
parent 289e60fcd3
commit 7a36c249f8
2 changed files with 6 additions and 6 deletions

View File

@ -410,6 +410,8 @@ func seckey*(kp: SkKeyPair): SkSecretKey =
doAssert res == 1, "Can't fail, per documentation"
SkSecretKey(data: key)
func `pubkey=`*(kp: var SkKeyPair, sk: SkPublicKey) {.deprecated: "Set the seckey instead".} = discard
func `seckey=`*(kp: var SkKeyPair, sk: SkSecretKey) =
var newKp: SkKeyPair
let res = secp256k1_keypair_create(getContext(), addr newKp.data, sk.data.baseAddr)
@ -419,8 +421,6 @@ func `seckey=`*(kp: var SkKeyPair, sk: SkSecretKey) =
#TODO: Raise an exception? Old behaviour would just set the secret key to an invalid key.
discard
func `pubkey=`*(kp: var SkKeyPair, sk: SkPublicKey) {.deprecated: "Set the seckey instead".} = discard
proc random*(T: type SkKeyPair, rng: Rng): SkResult[T] =
## Generates new random key pair.
let seckey = ? SkSecretKey.random(rng)

View File

@ -36,6 +36,10 @@ suite "secp256k1":
SkPublicKey.fromHex(pk.toHex())[].toHex() == pk.toHex()
SkSecretKey.random(brokenRng).isErr
test "Keypairs":
check:
SkKeyPair.random(workingRng).isOk()
test "Signatures":
let
sk = SkSecretKey.random(workingRng)[]
@ -57,7 +61,3 @@ suite "secp256k1":
SkMessage.fromBytes([]).isErr()
SkMessage.fromBytes([0'u8]).isErr()
SkMessage.fromBytes(array[32, byte](msg0)).isOk()
test "Keypairs":
check:
SkKeyPair.random(workingRng).isOk()