-
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.
Refactored inits from Signatures (#363)
* wip * lint and missing tests
- Loading branch information
1 parent
276143f
commit 2524db2
Showing
13 changed files
with
296 additions
and
48 deletions.
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
...dixConnect/WalletInteraction/WalletToDappInteractionProofOfOwnership+Wrap+Functions.swift
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,8 @@ | ||
import Foundation | ||
import SargonUniFFI | ||
|
||
extension WalletToDappInteractionProofOfOwnership { | ||
public init(intentSignatureOfOwner: IntentSignatureOfOwner) { | ||
self = newWalletToDappInteractionProofOfOwnershipFromIntentSignatureOfOwner(intentSignatureOfOwner: intentSignatureOfOwner) | ||
} | ||
} |
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
65 changes: 65 additions & 0 deletions
65
...stCases/RadixConnect/WalletInteraction/WalletToDappInteractionProofOfOwnershipTests.swift
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,65 @@ | ||
import CustomDump | ||
import Foundation | ||
import Sargon | ||
import SargonUniFFI | ||
import XCTest | ||
|
||
final class WalletToDappInteractionProofOfOwnershipTests: TestCase { | ||
typealias SUT = WalletToDappInteractionProofOfOwnership | ||
|
||
func testNewFromIntentSignatures_Ed25519_Account() throws { | ||
let owner = AddressOfAccountOrPersona.account(.sample) | ||
let intentSignature = IntentSignature.sample // Ed25519 | ||
let sut = SUT(intentSignatureOfOwner: .init(owner: owner, intentSignature: intentSignature)) | ||
switch sut { | ||
case let .account(value): | ||
XCTAssertEqual(value.proof.curve, .curve25519) | ||
XCTAssertEqual(value.proof.publicKey, intentSignature.signatureWithPublicKey.publicKey) | ||
XCTAssertEqual(value.proof.signature, intentSignature.signatureWithPublicKey.signature) | ||
case .persona: | ||
XCTFail("Expected account proof") | ||
} | ||
} | ||
|
||
func testNewFromIntentSignatures_Ed25519_Persona() throws { | ||
let owner = AddressOfAccountOrPersona.identity(.sample) | ||
let intentSignature = IntentSignature.sample // Ed25519 | ||
let sut = SUT(intentSignatureOfOwner: .init(owner: owner, intentSignature: intentSignature)) | ||
switch sut { | ||
case .account: | ||
XCTFail("Expected persona proof") | ||
case let .persona(value): | ||
XCTAssertEqual(value.proof.curve, .curve25519) | ||
XCTAssertEqual(value.proof.publicKey, intentSignature.signatureWithPublicKey.publicKey) | ||
XCTAssertEqual(value.proof.signature, intentSignature.signatureWithPublicKey.signature) | ||
} | ||
} | ||
|
||
func testNewFromIntentSignatures_Secp256k1_Account() throws { | ||
let owner = AddressOfAccountOrPersona.account(.sample) | ||
let intentSignature = IntentSignature.sampleOther // Secp256k1 | ||
let sut = SUT(intentSignatureOfOwner: .init(owner: owner, intentSignature: intentSignature)) | ||
switch sut { | ||
case let .account(value): | ||
XCTAssertEqual(value.proof.curve, .secp256k1) | ||
XCTAssertEqual(value.proof.publicKey, intentSignature.signatureWithPublicKey.publicKey) | ||
XCTAssertEqual(value.proof.signature, intentSignature.signatureWithPublicKey.signature) | ||
case .persona: | ||
XCTFail("Expected account proof") | ||
} | ||
} | ||
|
||
func testNewFromIntentSignatures_Secp256k1_Persona() throws { | ||
let owner = AddressOfAccountOrPersona.identity(.sample) | ||
let intentSignature = IntentSignature.sampleOther // Secp256k1 | ||
let sut = SUT(intentSignatureOfOwner: .init(owner: owner, intentSignature: intentSignature)) | ||
switch sut { | ||
case .account: | ||
XCTFail("Expected persona proof") | ||
case let .persona(value): | ||
XCTAssertEqual(value.proof.curve, .secp256k1) | ||
XCTAssertEqual(value.proof.publicKey, intentSignature.signatureWithPublicKey.publicKey) | ||
XCTAssertEqual(value.proof.signature, intentSignature.signatureWithPublicKey.signature) | ||
} | ||
} | ||
} |
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
8 changes: 4 additions & 4 deletions
8
...-android/src/main/java/com/radixdlt/sargon/extensions/WalletToDappInteractionAuthProof.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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.WalletToDappInteractionAuthProof | ||
import com.radixdlt.sargon.newWalletToDappInteractionAuthProofFromIntentSignatureOfOwner | ||
import com.radixdlt.sargon.IntentSignatureOfOwner | ||
import com.radixdlt.sargon.SignatureWithPublicKey | ||
import com.radixdlt.sargon.newWalletToDappInteractionAuthProofFromSignatureWithPublicKey | ||
|
||
fun WalletToDappInteractionAuthProof.Companion.init(intentSignatureOfOwner: IntentSignatureOfOwner) = | ||
newWalletToDappInteractionAuthProofFromIntentSignatureOfOwner(intentSignatureOfOwner = intentSignatureOfOwner) | ||
fun WalletToDappInteractionAuthProof.Companion.init(signatureWithPublicKey: SignatureWithPublicKey) = | ||
newWalletToDappInteractionAuthProofFromSignatureWithPublicKey(signatureWithPublicKey = signatureWithPublicKey) |
8 changes: 8 additions & 0 deletions
8
...d/src/main/java/com/radixdlt/sargon/extensions/WalletToDappInteractionProofOfOwnership.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,8 @@ | ||
package com.radixdlt.sargon.extensions | ||
|
||
import com.radixdlt.sargon.IntentSignatureOfOwner | ||
import com.radixdlt.sargon.WalletToDappInteractionProofOfOwnership | ||
import com.radixdlt.sargon.newWalletToDappInteractionProofOfOwnershipFromIntentSignatureOfOwner | ||
|
||
fun WalletToDappInteractionProofOfOwnership.Companion.init(intentSignatureOfOwner: IntentSignatureOfOwner) = | ||
newWalletToDappInteractionProofOfOwnershipFromIntentSignatureOfOwner(intentSignatureOfOwner = intentSignatureOfOwner) |
33 changes: 0 additions & 33 deletions
33
jvm/sargon-android/src/test/java/com/radixdlt/sargon/WalletToDappInteractionAuthProof.kt
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
jvm/sargon-android/src/test/java/com/radixdlt/sargon/WalletToDappInteractionAuthProofTest
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,29 @@ | ||
package com.radixdlt.sargon | ||
|
||
import com.radixdlt.sargon.extensions.init | ||
import com.radixdlt.sargon.extensions.publicKey | ||
import com.radixdlt.sargon.extensions.signature | ||
import com.radixdlt.sargon.samples.sample | ||
import org.junit.jupiter.api.Assertions.assertEquals | ||
import org.junit.jupiter.api.Test | ||
|
||
class WalletToDappInteractionAuthProofTest { | ||
|
||
@Test | ||
fun testNewFromIntentSignatures_Ed25519() { | ||
val signatureWithPublicKey = SignatureWithPublicKey.sample() // Ed25519 | ||
val sut = WalletToDappInteractionAuthProof.init(signatureWithPublicKey = signatureWithPublicKey) | ||
assertEquals(sut.curve, Slip10Curve.CURVE25519) | ||
assertEquals(sut.publicKey, signatureWithPublicKey.publicKey) | ||
assertEquals(sut.signature, signatureWithPublicKey.signature) | ||
} | ||
|
||
@Test | ||
fun testNewFromIntentSignatures_Secp256k1() { | ||
val signatureWithPublicKey = SignatureWithPublicKey.sample.other() // Secp256k1 | ||
val sut = WalletToDappInteractionAuthProof.init(signatureWithPublicKey = signatureWithPublicKey) | ||
assertEquals(sut.curve, Slip10Curve.SECP256K1) | ||
assertEquals(sut.publicKey, signatureWithPublicKey.publicKey) | ||
assertEquals(sut.signature, signatureWithPublicKey.signature) | ||
} | ||
} |
Oops, something went wrong.