/
views.go
87 lines (78 loc) · 2.19 KB
/
views.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package resolver
import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
)
func (r *resolver) GetPublicKeyChanged(address string) (*big.Int, error) {
instance := r.contract
identity := common.HexToAddress(address)
publicKeyChanged, err := instance.PublicKeyChanged(nil, identity)
if err != nil {
return nil, err
}
return publicKeyChanged, nil
}
func (r *resolver) GetAuthenticationChanged(address string) (*big.Int, error) {
instance := r.contract
identity := common.HexToAddress(address)
authenticationChanged, err := instance.AuthenticationChanged(nil, identity)
if err != nil {
return nil, err
}
return authenticationChanged, nil
}
func (r *resolver) GetAttributeChanged(address string) (*big.Int, error) {
instance := r.contract
identity := common.HexToAddress(address)
attributeChanged, err := instance.AttributeChanged(nil, identity)
if err != nil {
return nil, err
}
return attributeChanged, nil
}
func (r *resolver) IdentityOwner(address string) (string, error) {
instance := r.contract
identity := common.HexToAddress(address)
owner, err := instance.IdentityOwner(nil, identity)
if err != nil {
return "", err
}
return owner.Hex(), nil
}
func (r *resolver) ValidPublicKey(address, keyType, key string) (bool, error) {
instance := r.contract
identity := common.HexToAddress(address)
publickKeyType := [32]byte{}
copy(publickKeyType[:], keyType)
publickKey := [32]byte{}
hexKey, err := hexutil.Decode(key)
if err != nil {
return false, err
}
copy(publickKey[:], hexKey)
ok, err := instance.ValidPublicKey(nil, identity, publickKeyType,
publickKey)
if err != nil {
return false, err
}
return ok, nil
}
func (r *resolver) ValidAuthentication(address, keyType, key string) (bool, error) {
instance := r.contract
identity := common.HexToAddress(address)
authenticationType := [32]byte{}
copy(authenticationType[:], keyType)
authentication := [32]byte{}
hexKey, err := hexutil.Decode(key)
if err != nil {
return false, err
}
copy(authentication[:], hexKey)
ok, err := instance.ValidAuthentication(nil, identity, authenticationType,
authentication)
if err != nil {
return false, err
}
return ok, nil
}