Ranging from Nostr non-public and public keys, is it attainable to derive equal EVM keys?
It is easy to make use of the Nostr non-public key because the seed to generate an EVM priv/pubkey pair, however given somebody’s Nostr pubkey, is it attainable to derive the identical pubkey that the opposite get together would derive from their non-public key?
Nostr non-public keys are transformed into pubkeys utilizing BIP340
/// Produces the general public key from a non-public key
///
/// Takes privateKey, a 32-bytes hex-encoded string, i.e. 64 characters.
/// Returns a public key as additionally 32-bytes hex-encoded.
String getPublicKey(String privateKey) {
var d0 = BigInt.parse(privateKey, radix: 16);
ECPoint P = (secp256k1.G * d0)!;
return P.x!.toBigInteger()!.toRadixString(16).padLeft(64, "0");
}
At the moment I can do that utilizing the next dart code:
EthPrivateKey getEthCredentials(String nostrPrivateKey) {
return EthPrivateKey.fromHex(hex.encode(hex.decode(nostrPrivateKey)));
}
EthereumAddress getEthAddressFromPublicKey(String bip340PublicKey) {
ultimate ecCurve = ECCurve_secp256k1();
Uint8List publicKeyBytes = Uint8List.fromList(hex.decode(bip340PublicKey));
// Guarantee the general public key's within the appropriate format
if (publicKeyBytes.size == 32) {
// Add the 0x02 prefix for compressed public key
publicKeyBytes = Uint8List.fromList([0x02] + publicKeyBytes);
} else if (publicKeyBytes.size == 64) {
// Add the 0x04 prefix for uncompressed public key
publicKeyBytes = Uint8List.fromList([0x04] + publicKeyBytes);
}
// Decode the general public key
ultimate ecPoint = ecCurve.curve.decodePoint(publicKeyBytes);
ultimate uncompressedPublicKey =
ecPoint!.getEncoded(false).sublist(1); // Take away the prefix byte
// Generate Ethereum deal with from the uncompressed public key
return EthereumAddress.fromPublicKey(uncompressedPublicKey);
}
However this does not enable me to derive new addresses, so these could be single-use addresses.