Comments (2)
Hi,
basically depends if you are using a ed25519 or bip32-ed25519 (extended key) signing method
Here the python example
#!/usr/bin/env python
# Sign a transactions
from pycardano import *
seed = bytes.fromhex("bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e8")
print(seed.hex())
# bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e8
tx_hash = bytes.fromhex("0f1b6d09c85eaec039f086c96c5dfc05adc4ca413e2886bd08e72a8c2cafc03f")
print(tx_hash.hex())
# 0f1b6d09c85eaec039f086c96c5dfc05adc4ca413e2886bd08e72a8c2cafc03f
psk = SigningKey(seed)
sgn = psk.sign(tx_hash)
print(sgn.hex())
# 465727709060d0081e625127007f727165962fde69fc091a1ba8a94c1ac3fc42c9a225f31a3108ad593492d0fbfbc8e036b53f5ed6aef04c1a7388b06de70304
seed = bytes.fromhex("bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e80000000000000000000000000000000000000000000000000000000000000000")
epsk = ExtendedSigningKey(seed)
esgn = epsk.sign(tx_hash)
print(esgn.hex())
# 0eb1d55aca6d9d144f623943bc0928749110f99430cb9360e103a089b24be976c409c957c79bdfcde24fae1aea0f8b1454791db42918ea86bd1da61f2f14f00b
and the go example
import (
"encoding/hex"
"fmt"
"github.com/echovl/cardano-go/crypto"
"github.com/echovl/ed25519"
)
func main() {
seed, _ := hex.DecodeString("bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e8")
fmt.Println(hex.EncodeToString(seed))
// bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e8
tx_hash, _ := hex.DecodeString("0f1b6d09c85eaec039f086c96c5dfc05adc4ca413e2886bd08e72a8c2cafc03f")
fmt.Println(hex.EncodeToString(tx_hash))
// 0f1b6d09c85eaec039f086c96c5dfc05adc4ca413e2886bd08e72a8c2cafc03f
key := ed25519.NewKeyFromSeed(seed)
sgn := ed25519.Sign(key, tx_hash)
fmt.Println(hex.EncodeToString(sgn))
// 465727709060D0081E625127007F727165962FDE69FC091A1BA8A94C1AC3FC42C9A225F31A3108AD593492D0FBFBC8E036B53F5ED6AEF04C1A7388B06DE70304
seed, _ = hex.DecodeString("bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e80000000000000000000000000000000000000000000000000000000000000000")
var psk crypto.PrvKey = seed
fmt.Println(hex.EncodeToString(psk))
// bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e80000000000000000000000000000000000000000000000000000000000000000
sign := psk.Sign(tx_hash)
fmt.Println(hex.EncodeToString(sign))
// 0eb1d55aca6d9d144f623943bc0928749110f99430cb9360e103a089b24be976a752589f37d6c917b4e4337ede3ab338319203215960854d1a1257c3caa67d0e
}
from cardano-go.
@echovl
Colud you close this issue?
from cardano-go.
Related Issues (20)
- how to set socket path in cardano wallet ? HOT 1
- Support Byron addresses for output addresses HOT 1
- Add BigNum type
- Add support for Alonzo hardfork
- Cannot generate same address use same mnemonic with cardano java lib HOT 2
- Update fee calculation
- Restructure lib api
- Add multiasset support HOT 5
- Add Deserialize function for Tx model
- Avoid building transaction in AddChangeIfNeeded of TxBuilder HOT 6
- Deserialize not working for Amount.Inputs HOT 3
- Incorrect min amount for multiasset transaction HOT 5
- Why cannot use TASKFILE instead of MAKE?
- Add support for preprod testnet HOT 1
- Expose some utilities functions from the bech32 internal package
- Add support for building partially signed transaction (especially delegation ones)
- Add support for koios as node backend
- Add support for StakeAddress output
- Add support for CIP 68 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cardano-go.