Skip to content

Commit

Permalink
Merge branch 'release/v1.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
quvox committed Aug 4, 2019
2 parents 2d59687 + 976ed64 commit 2741f9b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,9 @@
CHANGELOG
====

## v1.4.4
* bug fix

## v1.4.3
* Add utility to include signature (SignAndAdd function)
* Note that the function does not work correctly for a transaction with BBcReference
Expand Down
2 changes: 1 addition & 1 deletion crossref.go
Expand Up @@ -74,7 +74,7 @@ func (p *BBcCrossRef) Pack() ([]byte, error) {
buf := new(bytes.Buffer)

PutBigInt(buf, &p.DomainID, DomainIDLength)
PutBigInt(buf, &p.TransactionID, 32)
PutBigInt(buf, &p.TransactionID, p.IdLengthConf.TransactionIdLength)

return buf.Bytes(), nil
}
Expand Down
2 changes: 2 additions & 0 deletions keypair.go
Expand Up @@ -95,6 +95,7 @@ func (k *KeyPair) ConvertFromPem(pem string, compressionMode int) {
k.Pubkey = pubkey[:lenPubkey]
k.Privkey = privkey[:lenPrivkey]
k.CurveType = int(curveType)
k.CompressionType = compressionMode
}

// ConvertFromPem imports DER formatted private key
Expand All @@ -110,6 +111,7 @@ func (k *KeyPair) ConvertFromDer(der []byte, compressionMode int) {
k.Pubkey = pubkey[:lenPubkey]
k.Privkey = privkey[:lenPrivkey]
k.CurveType = int(curveType)
k.CompressionType = compressionMode
}

// ReadX509 imports X.509 public key certificate
Expand Down
2 changes: 1 addition & 1 deletion reference.go
Expand Up @@ -140,7 +140,7 @@ func (p *BBcReference) AddSignature(userID *[]byte, sig *BBcSignature) error {
func (p *BBcReference) Pack() ([]byte, error) {
buf := new(bytes.Buffer)

PutBigInt(buf, &p.AssetGroupID, p.IdLengthConf.TransactionIdLength)
PutBigInt(buf, &p.AssetGroupID, p.IdLengthConf.AssetGroupIdLength)
PutBigInt(buf, &p.TransactionID, p.IdLengthConf.TransactionIdLength)
Put2byte(buf, p.EventIndexInRef)
Put2byte(buf, uint16(len(p.SigIndices)))
Expand Down
12 changes: 4 additions & 8 deletions transaction.go
Expand Up @@ -210,10 +210,8 @@ func (p *BBcTransaction) SetSigIndex(userID []byte, idx int) {

// Sign TransactionID using private key in the given keypair
func (p *BBcTransaction) Sign(keypair *KeyPair) ([]byte, error) {
if p.TransactionID == nil {
p.Digest()
}
signature := keypair.Sign(p.TransactionID)
digest := p.Digest()
signature := keypair.Sign(digest)
if signature == nil {
return nil, errors.New("fail to sign")
}
Expand All @@ -222,10 +220,8 @@ func (p *BBcTransaction) Sign(keypair *KeyPair) ([]byte, error) {

// SignAndAdd signs to TransactionID and add BBcSignature in the transaction
func (p *BBcTransaction) SignAndAdd(keypair *KeyPair, userID []byte, noPubkey bool) error {
if p.TransactionID == nil {
p.Digest()
}
signature := keypair.Sign(p.TransactionID)
digest := p.Digest()
signature := keypair.Sign(digest)
if signature == nil {
return errors.New("fail to sign")
}
Expand Down

0 comments on commit 2741f9b

Please sign in to comment.