Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Secp256k1 module #15

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 31 additions & 14 deletions sdk/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,9 +967,9 @@ func buildTransfer(amount *big.Int, target *keypair.PublicKey, sourcePurse strin

if target.Tag == keypair.KeyTagEd25519 {
accountHex = ed25519.AccountHash(target.PubKeyData)
} else {
// FIXME: implement secp256k1 module
return nil
}
if target.Tag == keypair.KeyTagSecp256k1 {
accountHex = hex.EncodeToString(append([]byte{0x02}, target.PubKeyData...))
}

idValue := Value{
Expand Down Expand Up @@ -1006,17 +1006,34 @@ func buildTransfer(amount *big.Int, target *keypair.PublicKey, sourcePurse strin
argsOrder = append(make([]string, 0), "amount", "target", "sourcePurse", "id")
}

args := NewRunTimeArgs(map[string]Value{
"amount": {
Tag: types.CLTypeU512,
StringBytes: hex.EncodeToString(amountBytes),
},
"target": {
Tag: types.CLTypeByteArray,
StringBytes: accountHex,
},
"id": idValue,
}, argsOrder)
var args *RuntimeArgs
if target.Tag == keypair.KeyTagEd25519 {
args = NewRunTimeArgs(map[string]Value{
"amount": {
Tag: types.CLTypeU512,
StringBytes: hex.EncodeToString(amountBytes),
},
"target": {
Tag: types.CLTypeByteArray,
StringBytes: accountHex,
},
"id": idValue,
}, argsOrder)
}

if target.Tag == keypair.KeyTagSecp256k1 {
args = NewRunTimeArgs(map[string]Value{
"amount": {
Tag: types.CLTypeU512,
StringBytes: hex.EncodeToString(amountBytes),
},
"target": {
Tag: types.CLTypePublicKey,
StringBytes: accountHex,
},
"id": idValue,
}, argsOrder)
}

if sourcePurse != "" {
args.Args["source"] = Value{Tag: types.CLTypeURef, StringBytes: sourcePurse}
Expand Down