mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
crypto.ecdsa: improve safety checking, unify signing (and verifying) api to accept options (#23463)
This commit is contained in:
parent
3c4878063e
commit
c2b7dbf9b4
8 changed files with 752 additions and 109 deletions
16
vlib/crypto/ecdsa/example/example1.v
Normal file
16
vlib/crypto/ecdsa/example/example1.v
Normal file
|
@ -0,0 +1,16 @@
|
|||
import crypto.ecdsa
|
||||
|
||||
fn main() {
|
||||
// create secp256r1, NIST P-256 curve key pair
|
||||
pbkey, pvkey := ecdsa.generate_key()!
|
||||
|
||||
message_tobe_signed := 'Hello ecdsa'.bytes()
|
||||
// create signature with recommended hash
|
||||
signature := pvkey.sign(message_tobe_signed, hash_config: .with_recommended_hash)!
|
||||
|
||||
// verified the message with signature
|
||||
verified := pbkey.verify(message_tobe_signed, signature, hash_config: .with_recommended_hash)!
|
||||
dump(verified) // should true
|
||||
pbkey.free()
|
||||
pvkey.free()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue