-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathstatement_example_test.go
43 lines (35 loc) · 1.15 KB
/
statement_example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package keys_test
import (
"bytes"
"encoding/json"
"fmt"
"log"
"github.com/keys-pub/keys"
)
func ExampleStatement() {
sk := keys.NewEdX25519KeyFromSeed(testSeed(0x01))
st := &keys.Statement{
KID: sk.ID(),
Data: bytes.Repeat([]byte{0x01}, 16),
Type: "test",
}
if err := st.Sign(sk); err != nil {
log.Fatal(err)
}
data := st.BytesToSign()
fmt.Printf("%s\n", string(data))
b, err := st.Bytes()
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", string(b))
b, err = json.Marshal(st)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", string(b))
// Output:
// {".sig":"","data":"AQEBAQEBAQEBAQEBAQEBAQ==","kid":"kex132yw8ht5p8cetl2jmvknewjawt9xwzdlrk2pyxlnwjyqrdq0dawqqph077","type":"test"}
// {".sig":"CFD9cK9gIB3sAEqpDwmZM0JFFO4/+RpX9uoAD25G3F1o8Af+pTk6pI4GPqAZ5FhEw1rUDfL02Qnohtx05LQxAg==","data":"AQEBAQEBAQEBAQEBAQEBAQ==","kid":"kex132yw8ht5p8cetl2jmvknewjawt9xwzdlrk2pyxlnwjyqrdq0dawqqph077","type":"test"}
// {".sig":"CFD9cK9gIB3sAEqpDwmZM0JFFO4/+RpX9uoAD25G3F1o8Af+pTk6pI4GPqAZ5FhEw1rUDfL02Qnohtx05LQxAg==","data":"AQEBAQEBAQEBAQEBAQEBAQ==","kid":"kex132yw8ht5p8cetl2jmvknewjawt9xwzdlrk2pyxlnwjyqrdq0dawqqph077","type":"test"}
}