forked from winderica/kryptology
-
Notifications
You must be signed in to change notification settings - Fork 0
/
proof_message.go
79 lines (63 loc) · 1.83 KB
/
proof_message.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
//
// Copyright Coinbase, Inc. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
package common
import (
"io"
"github.com/coinbase/kryptology/pkg/core/curves"
)
// ProofMessage classifies how a message is presented in a proof
// Either Revealed or Hidden. Hidden has two sub categories:
// proof specific i.e. the message is only used for this proof or
// shared i.e. the message should be proved to be common across proofs
type ProofMessage interface {
// IsHidden indicates the message should be hidden
IsHidden() bool
// GetBlinding is used for hidden messages
// blindings can either be proof specific to a signature
// or involved with other proofs like boundchecks,
// set memberships, or inequalities so the blinding
// factor is shared among proofs to produce a common
// schnorr linking proof
GetBlinding(reader io.Reader) curves.Scalar
// GetMessage returns the underlying message
GetMessage() curves.Scalar
}
type RevealedMessage struct {
Message curves.Scalar
}
func (r RevealedMessage) IsHidden() bool {
return false
}
func (r RevealedMessage) GetBlinding(reader io.Reader) curves.Scalar {
return nil
}
func (r RevealedMessage) GetMessage() curves.Scalar {
return r.Message
}
type ProofSpecificMessage struct {
Message curves.Scalar
}
func (ps ProofSpecificMessage) IsHidden() bool {
return true
}
func (ps ProofSpecificMessage) GetBlinding(reader io.Reader) curves.Scalar {
return ps.Message.Random(reader)
}
func (ps ProofSpecificMessage) GetMessage() curves.Scalar {
return ps.Message
}
type SharedBlindingMessage struct {
Message, Blinding curves.Scalar
}
func (ps SharedBlindingMessage) IsHidden() bool {
return true
}
func (ps SharedBlindingMessage) GetBlinding(reader io.Reader) curves.Scalar {
return ps.Blinding
}
func (ps SharedBlindingMessage) GetMessage() curves.Scalar {
return ps.Message
}