-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unchecked-extrinsic): ecdsa signature verification (#303)
- Loading branch information
Showing
10 changed files
with
546 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule goscale
updated
34 files
+3 −1 | .github/workflows/test.yaml | |
+3 −3 | README.md | |
+4 −4 | boolean_test.go | |
+3 −2 | codecov.yaml | |
+48 −2 | common_test.go | |
+3 −3 | compact.go | |
+14 −4 | compact_test.go | |
+9 −9 | dictionary.go | |
+16 −6 | dictionary_test.go | |
+2 −2 | empty_test.go | |
+4 −4 | i128.go | |
+14 −4 | i128_test.go | |
+2 −2 | i16.go | |
+13 −3 | i16_test.go | |
+2 −2 | i32.go | |
+13 −3 | i32_test.go | |
+2 −2 | i64.go | |
+13 −3 | i64_test.go | |
+2 −2 | i8.go | |
+13 −3 | i8_test.go | |
+2 −1 | numeric_test.go | |
+4 −6 | option.go | |
+82 −83 | option_test.go | |
+21 −11 | result.go | |
+56 −379 | result_test.go | |
+8 −8 | sequence.go | |
+127 −32 | sequence_test.go | |
+16 −16 | tuple_test.go | |
+14 −4 | u128_test.go | |
+13 −3 | u16_test.go | |
+14 −4 | u32_test.go | |
+13 −3 | u64_test.go | |
+3 −3 | u8_test.go | |
+6 −6 | varying_data_test.go |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package types | ||
|
||
import ( | ||
"bytes" | ||
|
||
sc "github.com/LimeChain/goscale" | ||
) | ||
|
||
const ( | ||
EcdsaVerifyErrorBadRS sc.U8 = iota | ||
EcdsaVerifyErrorBadV | ||
EcdsaVerifyErrorBadSignature | ||
) | ||
|
||
func NewEcdsaVerifyErrorBadRS() EcdsaVerifyError { | ||
return EcdsaVerifyError(sc.NewVaryingData(EcdsaVerifyErrorBadRS)) | ||
} | ||
|
||
func NewEcdsaVerifyErrorBadV() EcdsaVerifyError { | ||
return EcdsaVerifyError(sc.NewVaryingData(EcdsaVerifyErrorBadV)) | ||
} | ||
|
||
func NewEcdsaVerifyErrorBadSignature() EcdsaVerifyError { | ||
return EcdsaVerifyError(sc.NewVaryingData(EcdsaVerifyErrorBadSignature)) | ||
} | ||
|
||
type EcdsaVerifyError sc.VaryingData | ||
|
||
func (err EcdsaVerifyError) Encode(buffer *bytes.Buffer) error { | ||
if len(err) == 0 { | ||
return newTypeError("EcdsaVerifyError") | ||
} | ||
return err[0].Encode(buffer) | ||
} | ||
|
||
func DecodeEcdsaVerifyError(buffer *bytes.Buffer) (EcdsaVerifyError, error) { | ||
b, err := sc.DecodeU8(buffer) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
switch b { | ||
case EcdsaVerifyErrorBadRS: | ||
return NewEcdsaVerifyErrorBadRS(), nil | ||
case EcdsaVerifyErrorBadV: | ||
return NewEcdsaVerifyErrorBadV(), nil | ||
case EcdsaVerifyErrorBadSignature: | ||
return NewEcdsaVerifyErrorBadSignature(), nil | ||
default: | ||
return nil, newTypeError("EcdsaVerifyError") | ||
} | ||
} | ||
|
||
func (err EcdsaVerifyError) Bytes() []byte { | ||
return sc.EncodedBytes(err) | ||
} | ||
|
||
func (err EcdsaVerifyError) Error() string { | ||
if len(err) == 0 { | ||
return newTypeError("EcdsaVerifyError").Error() | ||
} | ||
|
||
switch err[0] { | ||
case EcdsaVerifyErrorBadRS: | ||
return "Bad RS" | ||
case EcdsaVerifyErrorBadV: | ||
return "Bad V" | ||
case EcdsaVerifyErrorBadSignature: | ||
return "Bad signature" | ||
default: | ||
return newTypeError("EcdsaVerifyError").Error() | ||
} | ||
} |
Oops, something went wrong.