0 branches
Tree Top files
Code
Clone with HTTPS:
56 years ago
..
example all: super_batch3 fixes last Apr 13 4.21 KB
ecdsa.c.v crypto.ecdsa: fixes last Apr 18 6.91 KB
ecdsa.v all: fix tests last Apr 24 17.89 KB
util.v all: fix tests last Apr 24 6.94 KB
util_test.v all: super_batch3 fixes last Apr 13 7.89 KB

ecdsa

ecdsa module for V language. Its a wrapper on top of openssl ecdsa functionality. Its currently (expanded) to support the following curves:

Example

import crypto.ecdsa

fn main() {
    // create default NIST P-256 secp256r1 curve key pair. If you wish to generate another curve,
    // use: `pbkey, pvkey := ecdsa.generate_key(nid: .secp521r1)!` instead.
    pbkey, pvkey := ecdsa.generate_key()!

    message_tobe_signed := 'Hello ecdsa'.bytes()
    // create a signature with the recommended hash
    signature := pvkey.sign(message_tobe_signed)!

    // verify the message with the signature
    verified := pbkey.verify(message_tobe_signed, signature)!
    dump(verified) // should be true

    // free allocated keys when you have done with your work.
    pbkey.free()
    pvkey.free()
}