mirror of
https://github.com/vlang/v.git
synced 2025-09-16 16:02:29 +03:00
x.crypto.slhdsa: add a SLH-DSA implementation, a stateless hash-based DSA, a post quantum cryptographic module (#24086)
This commit is contained in:
parent
12afd051bb
commit
a8a4507237
11 changed files with 1513 additions and 0 deletions
26
vlib/x/crypto/slhdsa/examples/example0.v
Normal file
26
vlib/x/crypto/slhdsa/examples/example0.v
Normal file
|
@ -0,0 +1,26 @@
|
|||
module main
|
||||
|
||||
import x.crypto.slhdsa
|
||||
|
||||
fn main() {
|
||||
// creates default key
|
||||
mut pvkey := slhdsa.PrivateKey.new()!
|
||||
|
||||
// example of message
|
||||
xmsg := 'Sample message'.bytes()
|
||||
|
||||
// signing the message with the key
|
||||
sig := pvkey.sign(xmsg)!
|
||||
|
||||
// example of public key
|
||||
mut pbkey := pvkey.public_key()!
|
||||
|
||||
// verify signature with the public key
|
||||
verified := pbkey.verify(sig, xmsg)!
|
||||
dump(verified) // true
|
||||
assert verified == true
|
||||
|
||||
// release the resources
|
||||
pvkey.free()
|
||||
pbkey.free()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue