Skip to content

Commit

Permalink
Merge pull request #26 from dfinity/enzoh/codec
Browse files Browse the repository at this point in the history
Implement signature encoding routine
  • Loading branch information
enzoh authored Aug 18, 2021
2 parents 3e2de90 + 634a346 commit 74c20ed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.6.1

- Upgrade encoding library.

## v1.6.0

- Add `shortlist` command to print the available commands.
Expand All @@ -18,7 +22,7 @@

## v1.3.0

- Upgrade HD crypto library dependency.
- Upgrade crypto library dependency.

## v1.2.0

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MAJOR ?= 1
MINOR ?= 6
PATCH ?= 0
PATCH ?= 1

LDFLAGS := -X=main.MAJOR=$(MAJOR)
LDFLAGS += -X=main.MINOR=$(MINOR)
Expand Down
9 changes: 9 additions & 0 deletions codec/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,12 @@ func EncodeECPubKey(pubKey *btcec.PublicKey) ([]byte, error) {
},
})
}

func EncodeECSig(sig *btcec.Signature) []byte {
var buf [64]byte
r := sig.R.Bytes()
s := sig.S.Bytes()
copy(buf[(32-len(r)):], r)
copy(buf[(64-len(s)):], s)
return buf[:]
}

0 comments on commit 74c20ed

Please sign in to comment.