| 1 | module main |
| 2 | |
| 3 | import x.crypto.slhdsa |
| 4 | |
| 5 | fn main() { |
| 6 | // creates default key |
| 7 | mut pvkey := slhdsa.PrivateKey.new()! |
| 8 | |
| 9 | // example of message |
| 10 | xmsg := 'Sample message'.bytes() |
| 11 | |
| 12 | // signing the message with the key |
| 13 | sig := pvkey.sign(xmsg)! |
| 14 | |
| 15 | // example of public key |
| 16 | mut pbkey := pvkey.public_key()! |
| 17 | |
| 18 | // verify signature with the public key |
| 19 | verified := pbkey.verify(sig, xmsg)! |
| 20 | dump(verified) // true |
| 21 | assert verified == true |
| 22 | |
| 23 | // release the resources |
| 24 | pvkey.free() |
| 25 | pbkey.free() |
| 26 | } |
| 27 | |