Skip to content

Commit

Permalink
simpler approach
Browse files Browse the repository at this point in the history
  • Loading branch information
wiyarmir committed Oct 15, 2024
1 parent 3c6fa5c commit 76355f4
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public data class Ed25519Keypair(
public companion object {
public fun fromSecretKeyBytes(bytes: ByteArray): Ed25519Keypair = when (bytes.size) {
// [secretKey(32)]
32 -> {
val publicKeyBytes = generatePublicKeyBytes(bytes)
Ed25519Keypair(PublicKey(publicKeyBytes), bytes + publicKeyBytes)
}
32 -> TweetNaCl.Signature.generateKey(bytes + ByteArray(32))
// [secretKey(32)|publicKey(32)]
64 -> {
val publicKey = PublicKey(bytes.sliceArray(32 until 64))
Expand All @@ -48,5 +45,3 @@ public data class Ed25519Keypair(
fromSecretKeyBytes(base58.decodeBase58())
}
}

internal expect fun generatePublicKeyBytes(secretKey: ByteArray): ByteArray

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
---
extern int is_on_curve(const unsigned char *);
extern int public_key_from_secret(unsigned char *, unsigned char *);

This file was deleted.

10 changes: 0 additions & 10 deletions tweetnacl-multiplatform/vendor/tweetnacl/tweetnacl.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,14 +814,4 @@ int is_on_curve(const u8 p[32])
return unpackneg(q, p);
}

int public_key_from_secret(u8 *sk, u8 *pk)
{
gf a[4];

scalarbase(a, sk);
pack(pk, a);

return 0;
}

// END curve additions

0 comments on commit 76355f4

Please sign in to comment.