@@ -22,15 +22,15 @@ type DecodeFunc func(BytesReader) (Varsig, error)
22
22
23
23
// Registry contains a mapping between known signing algorithms and
24
24
// functions that can parse varsigs for that signing algorithm.
25
- type Registry map [Discriminator ]DecodeFunc
25
+ type Registry map [Algorithm ]DecodeFunc
26
26
27
27
// DefaultRegistry provides a Registry containing the mappings for the
28
28
// signing algorithms which have an implementation within this library.
29
29
func DefaultRegistry () Registry {
30
- return map [Discriminator ]DecodeFunc {
31
- DiscriminatorRSA : decodeRSA ,
32
- DiscriminatorEdDSA : decodeEdDSA ,
33
- DiscriminatorECDSA : decodeECDSA ,
30
+ return map [Algorithm ]DecodeFunc {
31
+ AlgorithmRSA : decodeRSA ,
32
+ AlgorithmEdDSA : decodeEdDSA ,
33
+ AlgorithmECDSA : decodeECDSA ,
34
34
}
35
35
}
36
36
@@ -41,7 +41,7 @@ func NewRegistry() Registry {
41
41
42
42
// Register allows new mappings between a signing algorithm and its parsing
43
43
// function to the Registry.
44
- func (rs Registry ) Register (alg Discriminator , decodeFunc DecodeFunc ) {
44
+ func (rs Registry ) Register (alg Algorithm , decodeFunc DecodeFunc ) {
45
45
rs [alg ] = decodeFunc
46
46
}
47
47
@@ -63,7 +63,7 @@ func (rs Registry) DecodeStream(r BytesReader) (Varsig, error) {
63
63
return nil , fmt .Errorf ("%w: expected %d, got %d" , ErrBadPrefix , Prefix , pre )
64
64
}
65
65
66
- vers , disc , err := rs .decodeVersAnddisc (r )
66
+ vers , algo , err := rs .decodeVersAndAlgo (r )
67
67
if err != nil {
68
68
return nil , err
69
69
}
@@ -72,15 +72,15 @@ func (rs Registry) DecodeStream(r BytesReader) (Varsig, error) {
72
72
return nil , fmt .Errorf ("%w: %d" , ErrUnsupportedVersion , vers )
73
73
}
74
74
75
- decodeFunc , ok := rs [Discriminator ( disc )]
75
+ decodeFunc , ok := rs [Algorithm ( algo )]
76
76
if ! ok {
77
- return nil , fmt .Errorf ("%w: %x" , ErrUnknownDiscriminator , disc )
77
+ return nil , fmt .Errorf ("%w: %x" , ErrUnknownAlgorithm , algo )
78
78
}
79
79
80
80
return decodeFunc (r )
81
81
}
82
82
83
- func (rs Registry ) decodeVersAnddisc (r BytesReader ) (Version , Discriminator , error ) {
83
+ func (rs Registry ) decodeVersAndAlgo (r BytesReader ) (Version , Algorithm , error ) {
84
84
vers , err := binary .ReadUvarint (r )
85
85
if err != nil {
86
86
return Version (vers ), 0 , err
@@ -91,10 +91,10 @@ func (rs Registry) decodeVersAnddisc(r BytesReader) (Version, Discriminator, err
91
91
}
92
92
93
93
if vers >= 64 {
94
- return 0 , Discriminator (vers ), nil
94
+ return 0 , Algorithm (vers ), nil
95
95
}
96
96
97
- disc , err := binary .ReadUvarint (r )
97
+ algo , err := binary .ReadUvarint (r )
98
98
99
- return Version (vers ), Discriminator ( disc ), err
99
+ return Version (vers ), Algorithm ( algo ), err
100
100
}
0 commit comments