Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rohenaz committed Sep 13, 2024
1 parent a1c74e4 commit 59535a3
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions aip.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,19 @@ func (a *Aip) Validate() (bool, error) {
if err != nil {
return false, err
}

if pubKey, err := ec.PublicKeyFromString(a.AlgorithmSigningComponent); err != nil {
var pubKey *ec.PublicKey
var addr *script.Address
if pubKey, err = ec.PublicKeyFromString(a.AlgorithmSigningComponent); err != nil {
return false, err
} else if addr, err := script.NewAddressFromPublicKeyWithCompression(pubKey, true, wasCompressed); err != nil {
}
if addr, err = script.NewAddressFromPublicKeyWithCompression(
pubKey,
true,
wasCompressed); err != nil {
return false, err
} else {
a.AlgorithmSigningComponent = addr.AddressString
}
a.AlgorithmSigningComponent = addr.AddressString

}

// You get the address associated with the pki instead of the current address
Expand All @@ -97,12 +102,13 @@ func Sign(privateKey *ec.PrivateKey, algorithm Algorithm, message string) (a *Ai
a = &Aip{Algorithm: algorithm, Data: prependedData}

// Sign using the private key and the message
if sig, err := bsm.SignMessage(privateKey, []byte(strings.Join(prependedData, ""))); err != nil {
var sig []byte
if sig, err = bsm.SignMessage(privateKey, []byte(strings.Join(prependedData, ""))); err != nil {
return nil, err
} else {
a.Signature = base64.StdEncoding.EncodeToString(sig)
}

a.Signature = base64.StdEncoding.EncodeToString(sig)

// Store address vs pubkey
switch algorithm {
case BitcoinECDSA, BitcoinSignedMessage:
Expand Down

0 comments on commit 59535a3

Please sign in to comment.