-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathsignature_request.go
49 lines (38 loc) · 1.57 KB
/
signature_request.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
// (c) 2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package message
import (
"context"
"fmt"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
)
var (
_ Request = MessageSignatureRequest{}
_ Request = BlockSignatureRequest{}
)
// MessageSignatureRequest is used to request a warp message's signature.
type MessageSignatureRequest struct {
MessageID ids.ID `serialize:"true"`
}
func (s MessageSignatureRequest) String() string {
return fmt.Sprintf("MessageSignatureRequest(MessageID=%s)", s.MessageID.String())
}
func (s MessageSignatureRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error) {
return handler.HandleMessageSignatureRequest(ctx, nodeID, requestID, s)
}
// BlockSignatureRequest is used to request a warp message's signature.
type BlockSignatureRequest struct {
BlockID ids.ID `serialize:"true"`
}
func (s BlockSignatureRequest) String() string {
return fmt.Sprintf("BlockSignatureRequest(BlockID=%s)", s.BlockID.String())
}
func (s BlockSignatureRequest) Handle(ctx context.Context, nodeID ids.NodeID, requestID uint32, handler RequestHandler) ([]byte, error) {
return handler.HandleBlockSignatureRequest(ctx, nodeID, requestID, s)
}
// SignatureResponse is the response to a BlockSignatureRequest or MessageSignatureRequest.
// The response contains a BLS signature of the requested message, signed by the responding node's BLS private key.
type SignatureResponse struct {
Signature [bls.SignatureLen]byte `serialize:"true"`
}