Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit e2781e2

Browse files
committed
rename verifyingkey to publickey
1 parent 1e2d605 commit e2781e2

File tree

11 files changed

+71
-71
lines changed

11 files changed

+71
-71
lines changed

src/it/scala/stellar/sdk/DomainMatchersIT.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package stellar.sdk
22

33
import org.apache.commons.codec.binary.Hex
44
import org.specs2.matcher.{AnyMatchers, Matcher, MustExpectations, OptionMatchers, SequenceMatchersCreation}
5-
import org.stellar.sdk.xdr.{DecoratedSignature, Hash, PublicKey, SignerKey, Uint64, Memo => XDRMemo, Operation => XDROperation}
5+
import org.stellar.sdk.xdr.{DecoratedSignature, Hash, PublicKey => XDRPublicKey, SignerKey, Uint64, Memo => XDRMemo, Operation => XDROperation}
66
import stellar.sdk.op._
77

88
trait DomainMatchersIT extends AnyMatchers with MustExpectations with SequenceMatchersCreation with OptionMatchers {
@@ -41,8 +41,8 @@ trait DomainMatchersIT extends AnyMatchers with MustExpectations with SequenceMa
4141
signer.getEd25519.getUint256.toSeq mustEqual other.getEd25519.getUint256.toSeq
4242
}
4343

44-
def beEquivalentTo(other: VerifyingKey): Matcher[VerifyingKey] = beLike[VerifyingKey] {
45-
case VerifyingKey(pk) =>
44+
def beEquivalentTo(other: PublicKey): Matcher[PublicKey] = beLike[PublicKey] {
45+
case PublicKey(pk) =>
4646
Hex.encodeHex(pk.getAbyte) mustEqual Hex.encodeHex(other.pk.getAbyte)
4747
}
4848

@@ -67,7 +67,7 @@ trait DomainMatchersIT extends AnyMatchers with MustExpectations with SequenceMa
6767
memo.getText mustEqual other.getText
6868
}
6969

70-
def beEquivalentTo(other: PublicKey): Matcher[PublicKey] = beLike[PublicKey] {
70+
def beEquivalentTo(other: XDRPublicKey): Matcher[XDRPublicKey] = beLike[XDRPublicKey] {
7171
case pk =>
7272
pk.getDiscriminant mustEqual other.getDiscriminant
7373
pk.getEd25519.getUint256.toSeq mustEqual other.getEd25519.getUint256.toSeq

src/main/scala/stellar/sdk/Asset.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ case object NativeAsset extends Asset {
3939

4040
trait NonNativeAsset extends Asset {
4141
val code: String
42-
val issuer: VerifyingKey
42+
val issuer: PublicKey
4343
val typeString: String
4444
}
4545

@@ -48,7 +48,7 @@ trait NonNativeAsset extends Asset {
4848
*
4949
* @see <a href="https://www.stellar.org/developers/learn/concepts/assets.html" target="_blank">Assets</a>
5050
*/
51-
case class AssetTypeCreditAlphaNum4(code: String, issuer: VerifyingKey) extends NonNativeAsset {
51+
case class AssetTypeCreditAlphaNum4(code: String, issuer: PublicKey) extends NonNativeAsset {
5252
assert(code.nonEmpty, s"Asset's code '$code' cannot be empty")
5353
assert(code.length <= 4, s"Asset's code '$code' should have length no greater than 4")
5454

@@ -69,7 +69,7 @@ case class AssetTypeCreditAlphaNum4(code: String, issuer: VerifyingKey) extends
6969

7070
object AssetTypeCreditAlphaNum4 {
7171
def apply(code: String, keyPair: PublicKeyOps): AssetTypeCreditAlphaNum4 =
72-
AssetTypeCreditAlphaNum4(code, keyPair.asVerifyingKey)
72+
AssetTypeCreditAlphaNum4(code, keyPair.asPublicKey)
7373
}
7474

7575

@@ -78,7 +78,7 @@ object AssetTypeCreditAlphaNum4 {
7878
*
7979
* @see <a href="https://www.stellar.org/developers/learn/concepts/assets.html" target="_blank">Assets</a>
8080
*/
81-
case class AssetTypeCreditAlphaNum12(code: String, issuer: VerifyingKey) extends NonNativeAsset {
81+
case class AssetTypeCreditAlphaNum12(code: String, issuer: PublicKey) extends NonNativeAsset {
8282
assert(code.length >= 5 && code.length <= 12, s"Asset's code '$code' should have length between 5 & 12 inclusive")
8383

8484
override def toXDR: XDRAsset = {
@@ -98,5 +98,5 @@ case class AssetTypeCreditAlphaNum12(code: String, issuer: VerifyingKey) extends
9898

9999
object AssetTypeCreditAlphaNum12 {
100100
def apply(code: String, keyPair: PublicKeyOps): AssetTypeCreditAlphaNum12 =
101-
AssetTypeCreditAlphaNum12(code, keyPair.asVerifyingKey)
101+
AssetTypeCreditAlphaNum12(code, keyPair.asPublicKey)
102102
}

src/main/scala/stellar/sdk/KeyPair.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import java.util
66

77
import net.i2p.crypto.eddsa._
88
import net.i2p.crypto.eddsa.spec._
9-
import org.stellar.sdk.xdr._
9+
import org.stellar.sdk.xdr.{PublicKey => XDRPublicKey, _}
1010

1111
import scala.util.Try
1212

@@ -54,7 +54,7 @@ case class KeyPair(pk: EdDSAPublicKey, sk: EdDSAPrivateKey) extends PublicKeyOps
5454
}
5555
}
5656

57-
case class VerifyingKey(pk: EdDSAPublicKey) extends PublicKeyOps {
57+
case class PublicKey(pk: EdDSAPublicKey) extends PublicKeyOps {
5858

5959
override def hashCode(): Int = accountId.hashCode()
6060

@@ -63,7 +63,7 @@ case class VerifyingKey(pk: EdDSAPublicKey) extends PublicKeyOps {
6363
case _ => false
6464
}
6565

66-
override def toString: String = s"VerifyingKey($accountId)"
66+
override def toString: String = s"PublicKey($accountId)"
6767

6868
}
6969

@@ -93,8 +93,8 @@ trait PublicKeyOps {
9393
case _: SignatureException => false
9494
}.get
9595

96-
def getXDRPublicKey: PublicKey = {
97-
val publicKey = new PublicKey
96+
def getXDRPublicKey: XDRPublicKey = {
97+
val publicKey = new XDRPublicKey
9898
publicKey.setDiscriminant(PublicKeyType.PUBLIC_KEY_TYPE_ED25519)
9999
val uint256 = new Uint256
100100
uint256.setUint256(pk.getAbyte)
@@ -114,7 +114,7 @@ trait PublicKeyOps {
114114
/**
115115
* This key pair or verifying key without the private key.
116116
*/
117-
def asVerifyingKey = VerifyingKey(pk)
117+
def asPublicKey = PublicKey(pk)
118118

119119

120120
/**
@@ -123,7 +123,7 @@ trait PublicKeyOps {
123123
val signatureHint: Try[SignatureHint] = Try {
124124
val pkStream = new ByteArrayOutputStream
125125
val os = new XdrDataOutputStream(pkStream)
126-
PublicKey.encode(os, getXDRPublicKey)
126+
XDRPublicKey.encode(os, getXDRPublicKey)
127127
val pkBytes = pkStream.toByteArray
128128
val hintBytes = util.Arrays.copyOfRange(pkBytes, pkBytes.length - 4, pkBytes.length)
129129
val hint = new SignatureHint
@@ -181,21 +181,21 @@ object KeyPair {
181181
* Creates a new Stellar verifying key from a 32 byte address.
182182
*
183183
* @param publicKey The 32 byte public key.
184-
* @return { @link VerifyingKey}
184+
* @return { @link PublicKey }
185185
*/
186-
def fromPublicKey(publicKey: Array[Byte]): VerifyingKey = {
187-
VerifyingKey(new EdDSAPublicKey(new EdDSAPublicKeySpec(publicKey, ed25519)))
186+
def fromPublicKey(publicKey: Array[Byte]): PublicKey = {
187+
PublicKey(new EdDSAPublicKey(new EdDSAPublicKeySpec(publicKey, ed25519)))
188188
}
189189

190190
/**
191-
* Creates a new Stellar VerifyingKey from a strkey encoded Stellar account ID.
191+
* Creates a new Stellar PublicKey from a strkey encoded Stellar account ID.
192192
*
193193
* @param accountId The strkey encoded Stellar account ID.
194-
* @return { @link VerifyingKey}
194+
* @return { @link PublicKey}
195195
*/
196-
def fromAccountId(accountId: String): VerifyingKey = fromPublicKey(StrKey.decodeStellarAccountId(accountId))
196+
def fromAccountId(accountId: String): PublicKey = fromPublicKey(StrKey.decodeStellarAccountId(accountId))
197197

198-
def fromXDRPublicKey(key: PublicKey) = fromPublicKey(key.getEd25519.getUint256)
198+
def fromXDRPublicKey(key: XDRPublicKey) = fromPublicKey(key.getEd25519.getUint256)
199199

200200
/**
201201
* Generates a random Stellar keypair.

src/main/scala/stellar/sdk/op/AllowTrustOperation.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import org.stellar.sdk.xdr.Operation.OperationBody
55
import org.stellar.sdk.xdr.OperationType._
66
import org.stellar.sdk.xdr.{AccountID, AllowTrustOp}
77
import stellar.sdk._
8-
import stellar.sdk.{ByteArrays, KeyPair, VerifyingKey}
8+
import stellar.sdk.{ByteArrays, KeyPair, PublicKey}
99

1010
import scala.util.Try
1111

12-
case class AllowTrustOperation(trustor: VerifyingKey,
12+
case class AllowTrustOperation(trustor: PublicKey,
1313
assetCode: String,
1414
authorize: Boolean,
1515
sourceAccount: Option[PublicKeyOps] = None) extends Operation with ByteArrays {

src/test/scala/stellar/sdk/ArbitraryInput.scala

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ trait ArbitraryInput extends ScalaCheck {
1919

2020
implicit def arbKeyPair: Arbitrary[KeyPair] = Arbitrary(genKeyPair)
2121

22-
implicit def arbVerifyingKey: Arbitrary[VerifyingKey] = Arbitrary(genVerifyingKey)
22+
implicit def arbPublicKey: Arbitrary[PublicKey] = Arbitrary(genPublicKey)
2323

2424
implicit def arbAccount: Arbitrary[Account] = Arbitrary(genAccount)
2525

@@ -34,25 +34,25 @@ trait ArbitraryInput extends ScalaCheck {
3434
implicit def arbNonNativeAsset: Arbitrary[NonNativeAsset] = Arbitrary(genNonNativeAsset)
3535

3636
implicit def arbAccountMergeOperation: Arbitrary[AccountMergeOperation] = Arbitrary(genAccountMergeOperation)
37-
37+
3838
implicit def arbAllowTrustOperation: Arbitrary[AllowTrustOperation] = Arbitrary(genAllowTrustOperation)
39-
39+
4040
implicit def arbChangeTrustOperation: Arbitrary[ChangeTrustOperation] = Arbitrary(genChangeTrustOperation)
41-
41+
4242
implicit def arbCreateAccountOperation: Arbitrary[CreateAccountOperation] = Arbitrary(genCreateAccountOperation)
43-
43+
4444
implicit def arbCreatePassiveOfferOperation: Arbitrary[CreatePassiveOfferOperation] = Arbitrary(genCreatePassiveOfferOperation)
45-
45+
4646
implicit def arbWriteDataOperation: Arbitrary[WriteDataOperation] = Arbitrary(genWriteDataOperation)
47-
47+
4848
implicit def arbDeleteDataOperation: Arbitrary[DeleteDataOperation] = Arbitrary(genDeleteDataOperation)
49-
49+
5050
implicit def arbCreateOfferOperation: Arbitrary[CreateOfferOperation] = Arbitrary(genCreateOfferOperation)
51-
51+
5252
implicit def arbDeleteOfferOperation: Arbitrary[DeleteOfferOperation] = Arbitrary(genDeleteOfferOperation)
53-
53+
5454
implicit def arbUpdateOfferOperation: Arbitrary[UpdateOfferOperation] = Arbitrary(genUpdateOfferOperation)
55-
55+
5656
implicit def arbPathPaymentOperation: Arbitrary[PathPaymentOperation] = Arbitrary(genPathPaymentOperation)
5757

5858
implicit def arbPaymentOperation: Arbitrary[PaymentOperation] = Arbitrary(genPaymentOperation)
@@ -87,7 +87,7 @@ trait ArbitraryInput extends ScalaCheck {
8787

8888
def genSignerKey: Gen[SignerKey] = genKeyPair.map(_.getXDRSignerKey)
8989

90-
def genVerifyingKey: Gen[VerifyingKey] = genKeyPair.map(kp => VerifyingKey(kp.pk))
90+
def genPublicKey: Gen[PublicKey] = genKeyPair.map(kp => PublicKey(kp.pk))
9191

9292
def genAccount: Gen[Account] = for {
9393
kp <- genKeyPair
@@ -145,11 +145,11 @@ trait ArbitraryInput extends ScalaCheck {
145145
Gen.oneOf(AuthorizationRequiredFlag, AuthorizationRevocableFlag, AuthorizationImmutableFlag)
146146

147147
def genAccountMergeOperation: Gen[AccountMergeOperation] = for {
148-
destination <- genVerifyingKey
148+
destination <- genPublicKey
149149
} yield AccountMergeOperation(destination)
150150

151151
def genAllowTrustOperation = for {
152-
trustor <- genVerifyingKey
152+
trustor <- genPublicKey
153153
assetCode <- Gen.identifier.map(_.take(12))
154154
authorise <- Gen.oneOf(true, false)
155155
} yield AllowTrustOperation(trustor, assetCode, authorise)
@@ -159,7 +159,7 @@ trait ArbitraryInput extends ScalaCheck {
159159
} yield ChangeTrustOperation(limit)
160160

161161
def genCreateAccountOperation = for {
162-
destination <- genVerifyingKey
162+
destination <- genPublicKey
163163
startingBalance <- genNativeAmount
164164
} yield CreateAccountOperation(destination, startingBalance)
165165

@@ -206,18 +206,18 @@ trait ArbitraryInput extends ScalaCheck {
206206

207207
def genPathPaymentOperation = for {
208208
sendMax <- genAmount
209-
destAccount <- genVerifyingKey
209+
destAccount <- genPublicKey
210210
destAmount <- genAmount
211211
path <- Gen.listOf(genAsset)
212212
} yield PathPaymentOperation(sendMax, destAccount, destAmount, path)
213213

214214
def genPaymentOperation = for {
215-
destAccount <- genVerifyingKey
215+
destAccount <- genPublicKey
216216
amount <- genAmount
217217
} yield PaymentOperation(destAccount, amount)
218218

219219
def genSetOptionsOperation: Gen[SetOptionsOperation] = for {
220-
inflationDestination <- Gen.option(genVerifyingKey)
220+
inflationDestination <- Gen.option(genPublicKey)
221221
clearFlags <- Gen.option(Gen.nonEmptyContainerOf[Set, IssuerFlag](genIssuerFlag))
222222
setFlags <- Gen.option(Gen.nonEmptyContainerOf[Set, IssuerFlag](genIssuerFlag))
223223
masterKeyWeight <- Gen.option(Gen.choose(0, 255))
@@ -226,7 +226,7 @@ trait ArbitraryInput extends ScalaCheck {
226226
highThreshold <- Gen.option(Gen.choose(0, 255))
227227
homeDomain <- Gen.option(Gen.identifier)
228228
signer <- Gen.option{ for {
229-
accn <- genVerifyingKey
229+
accn <- genPublicKey
230230
weight <- Gen.choose(0, 255)
231231
} yield AccountSigner(accn, weight)}
232232
} yield SetOptionsOperation(inflationDestination, clearFlags, setFlags, masterKeyWeight, lowThreshold, medThreshold,
@@ -309,7 +309,7 @@ trait ArbitraryInput extends ScalaCheck {
309309

310310
def genOfferResp: Gen[OfferResp] = for {
311311
id <- Gen.posNum[Long]
312-
seller <- genVerifyingKey
312+
seller <- genPublicKey
313313
selling <- genAmount
314314
buying <- genAsset
315315
price <- genPrice
@@ -318,7 +318,7 @@ trait ArbitraryInput extends ScalaCheck {
318318
def genTransacted[O <: Operation](genOp: Gen[O]): Gen[Transacted[O]] = for {
319319
id <- Gen.posNum[Long]
320320
hash <- genHash
321-
source <- genVerifyingKey
321+
source <- genPublicKey
322322
createdAt <- genZonedDateTime
323323
op <- genOp
324324
} yield Transacted(id, hash, source, createdAt, op)
@@ -341,9 +341,9 @@ trait ArbitraryInput extends ScalaCheck {
341341
id <- Gen.identifier
342342
ledgerCloseTime <- genZonedDateTime
343343
offerId <- Gen.posNum[Long]
344-
baseAccount <- genVerifyingKey
344+
baseAccount <- genPublicKey
345345
baseAmount <- genAmount
346-
counterAccount <- genVerifyingKey
346+
counterAccount <- genPublicKey
347347
counterAmount <- genAmount
348348
baseIsSeller <- Gen.oneOf(true, false)
349349
} yield Trade(id, ledgerCloseTime, offerId, baseAccount, baseAmount, counterAccount, counterAmount, baseIsSeller)

src/test/scala/stellar/sdk/DomainMatchers.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import java.time.format.DateTimeFormatter
55

66
import org.apache.commons.codec.binary.Hex
77
import org.specs2.matcher.{AnyMatchers, Matcher, MustExpectations, OptionMatchers, SequenceMatchersCreation}
8-
import org.stellar.sdk.xdr.{DecoratedSignature, Hash, PublicKey, SignerKey, Uint64, Memo => XDRMemo, Operation => XDROperation}
8+
import org.stellar.sdk.xdr.{DecoratedSignature, Hash, PublicKey => XDRPublicKey, SignerKey, Uint64, Memo => XDRMemo, Operation => XDROperation}
99
import stellar.sdk._
1010
import stellar.sdk.op._
1111

@@ -45,8 +45,8 @@ trait DomainMatchers extends AnyMatchers with MustExpectations with SequenceMatc
4545
signer.getEd25519.getUint256.toSeq mustEqual other.getEd25519.getUint256.toSeq
4646
}
4747

48-
def beEquivalentTo(other: VerifyingKey): Matcher[VerifyingKey] = beLike[VerifyingKey] {
49-
case VerifyingKey(pk) =>
48+
def beEquivalentTo(other: PublicKey): Matcher[PublicKey] = beLike[PublicKey] {
49+
case PublicKey(pk) =>
5050
Hex.encodeHex(pk.getAbyte) mustEqual Hex.encodeHex(other.pk.getAbyte)
5151
}
5252

@@ -71,7 +71,7 @@ trait DomainMatchers extends AnyMatchers with MustExpectations with SequenceMatc
7171
memo.getText mustEqual other.getText
7272
}
7373

74-
def beEquivalentTo(other: PublicKey): Matcher[PublicKey] = beLike[PublicKey] {
74+
def beEquivalentTo(other: XDRPublicKey): Matcher[XDRPublicKey] = beLike[XDRPublicKey] {
7575
case pk =>
7676
pk.getDiscriminant mustEqual other.getDiscriminant
7777
pk.getEd25519.getUint256.toSeq mustEqual other.getEd25519.getUint256.toSeq

src/test/scala/stellar/sdk/KeyPairSpec.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ class KeyPairSpec extends Specification with ArbitraryInput with DomainMatchers
4040
"report its account id and secret seed and be reconstituted from these" >> prop { kp: KeyPair =>
4141
kp.accountId.toCharArray must haveLength(56)
4242
kp.accountId must startWith("G")
43-
KeyPair.fromPublicKey(kp.publicKey) must beEquivalentTo(kp.asVerifyingKey)
43+
KeyPair.fromPublicKey(kp.publicKey) must beEquivalentTo(kp.asPublicKey)
4444
KeyPair.fromSecretSeed(kp.secretSeed) must beEquivalentTo(kp)
4545
KeyPair.fromSecretSeed(kp.secretSeed.mkString) must beEquivalentTo(kp)
46-
KeyPair.fromAccountId(kp.accountId) must beEquivalentTo(kp.asVerifyingKey)
46+
KeyPair.fromAccountId(kp.accountId) must beEquivalentTo(kp.asPublicKey)
4747
}
4848
}
4949
}

0 commit comments

Comments
 (0)