v2 / vlib / x / crypto / slhdsa / usage_test.v
28 lines · 22 sloc · 671 bytes · a8a45072371795b72d2aaa145b8195cde71cb9db
Raw
1// Copyright (c) blackshirt. All rights reserved.
2// Use of this source code is governed by an MIT license
3// that can be found in the LICENSE file.
4// vtest build: has_modern_openssl?
5import x.crypto.slhdsa
6
7fn test_slhdsa_basic_default_functionality() ! {
8 // creates default key
9 mut pvkey := slhdsa.PrivateKey.new()!
10
11 // example of message
12 xmsg := 'Sample message'.bytes()
13
14 // signing the message with the key
15 sig := pvkey.sign(xmsg)!
16
17 // example of public key
18 mut pbkey := pvkey.public_key()!
19
20 // verify signature with the public key
21 verified := pbkey.verify(sig, xmsg)!
22 println(verified)
23 assert verified == true
24
25 // release
26 pvkey.free()
27 pbkey.free()
28}
29