-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use secp256k1_ec_pubkey_combine #397
Comments
Hey @POLAX7 👋 The function binding for Quick and dirty way to use func combine(_ pubkeys: [PublicKey]) {
let context = secp256k1.Context.rawRepresentation
var publicKey = secp256k1_pubkey()
var keys = pubkeys.map {
var newPubKey = secp256k1_pubkey()
$0.rawRepresentation.copyToUnsafeMutableBytes(of: &newPubKey.data)
let pointerKey: UnsafePointer<secp256k1_pubkey>? = withUnsafePointer(to: &newPubKey) { $0 }
return pointerKey
}
secp256k1_ec_pubkey_combine(context, &publicKey, &keys, pubkeys.count)
} |
Thank you for your replying. |
Do you have an example of what you want to do exactly? I can’t help much without a better understanding of your goal. |
I just want to calculate with |
@csjones |
I am also interested in using |
Hey @dariolass 👋 Thank you for the kind words! |
Awesome! The project I am trying to partly recreate is cashu. # taken from cashu/core/crypto/b_dhke.py
def step1_alice(
secret_msg: str, blinding_factor: Optional[PrivateKey] = None
) -> tuple[PublicKey, PrivateKey]:
Y: PublicKey = hash_to_curve(secret_msg.encode("utf-8"))
r = blinding_factor or PrivateKey()
B_: PublicKey = Y + r.pubkey # type: ignore
return B_, r
# taken from cashu/core/crypto/secp.py
class PublicKeyExt(PublicKey):
def __add__(self, pubkey2):
if isinstance(pubkey2, PublicKey):
new_pub = PublicKey()
new_pub.combine([self.public_key, pubkey2.public_key])
return new_pub
else:
raise TypeError("Cant add pubkey and %s" % pubkey2.__class__) For now I can use Hope this makes sense and thanks again for helping a newbie! |
@zeugmaster I opened up a draft pull request for the combine API here: #439 It would be valuable to try the draft API out and provide any feedback you may have. Additionally, starring this repo helps a lot too! 🙂 |
How to use
secp256k1_ec_pubkey_combine
?I'd like to use this function from secp256k1
But there is no interface from this library.
Would you like to show that how to use it?
Thank you.
The text was updated successfully, but these errors were encountered: