-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update notary private key implementation (#128)
* Update notary private key implementation * Address PR comments * Add exception annotation to sign method * Version bump
- Loading branch information
1 parent
d584767
commit 0c46ed7
Showing
8 changed files
with
132 additions
and
87 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "sargon" | ||
version = "0.7.3" | ||
version = "0.7.8" | ||
edition = "2021" | ||
build = "build.rs" | ||
|
||
|
60 changes: 60 additions & 0 deletions
60
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/Curve25519SecretKey.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.Ed25519Signature | ||
import com.radixdlt.sargon.Exactly32Bytes | ||
import com.radixdlt.sargon.Hash | ||
import com.radixdlt.sargon.NotarySignature | ||
import com.radixdlt.sargon.PublicKey | ||
import com.radixdlt.sargon.SignedIntentHash | ||
import com.radixdlt.sargon.androidNotarizeHashWithPrivateKeyBytes | ||
import com.radixdlt.sargon.androidSecretKeyGetPublicKeyFromPrivateKeyBytes | ||
import com.radixdlt.sargon.androidSignHashWithPrivateKeyBytes | ||
import com.radixdlt.sargon.annotation.KoverIgnore | ||
|
||
class Curve25519SecretKey( | ||
private val exactly32Bytes: Exactly32Bytes | ||
) { | ||
|
||
companion object { | ||
fun secureRandom(): Curve25519SecretKey = | ||
Curve25519SecretKey(exactly32Bytes = Exactly32Bytes.init(randomBagOfBytes(32))) | ||
} | ||
|
||
@Throws(SargonException::class) | ||
fun notarize(signedIntentHash: SignedIntentHash): NotarySignature = | ||
androidNotarizeHashWithPrivateKeyBytes( | ||
privateKeyBytes = exactly32Bytes, | ||
signedIntentHash = signedIntentHash | ||
) | ||
|
||
@Throws(SargonException::class) | ||
fun sign(hash: Hash): Ed25519Signature = | ||
androidSignHashWithPrivateKeyBytes( | ||
privateKeyBytes = exactly32Bytes, | ||
hash = hash | ||
) | ||
|
||
@Throws(SargonException::class) | ||
fun toPublicKey(): PublicKey.Ed25519 = | ||
androidSecretKeyGetPublicKeyFromPrivateKeyBytes(privateKeyBytes = exactly32Bytes).asGeneral() | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as Curve25519SecretKey | ||
|
||
return exactly32Bytes == other.exactly32Bytes | ||
} | ||
|
||
override fun hashCode(): Int { | ||
return exactly32Bytes.hashCode() | ||
} | ||
|
||
@KoverIgnore | ||
override fun toString(): String { | ||
return "Curve25519SecretKey(exactly32Bytes=$exactly32Bytes)" | ||
} | ||
|
||
|
||
} |
50 changes: 0 additions & 50 deletions
50
jvm/sargon-android/src/main/java/com/radixdlt/sargon/extensions/NotaryPrivateKey.kt
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
jvm/sargon-android/src/main/java/com/radixdlt/sargon/samples/Exactly32BytesSample.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.radixdlt.sargon.samples | ||
|
||
import com.radixdlt.sargon.Exactly32Bytes | ||
import com.radixdlt.sargon.annotation.UsesSampleValues | ||
import com.radixdlt.sargon.newExactly32BytesSample | ||
import com.radixdlt.sargon.newExactly32BytesSampleOther | ||
|
||
@UsesSampleValues | ||
val Exactly32Bytes.Companion.sample: Sample<Exactly32Bytes> | ||
get() = object : Sample<Exactly32Bytes> { | ||
override fun invoke(): Exactly32Bytes = newExactly32BytesSample() | ||
|
||
override fun other(): Exactly32Bytes = newExactly32BytesSampleOther() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters