Skip to content

Commit

Permalink
Merge pull request #162 from avianlabs/guillermo/add-typealias-and-re…
Browse files Browse the repository at this point in the history
…move-unused

add typealias and remove unused method
  • Loading branch information
wiyarmir authored Nov 14, 2024
2 parents 9d4cc70 + c273b58 commit 62e6a8e
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public data class SignedTransaction internal constructor(
override fun toString(): String =
"SignedTransaction(message=${originalMessage}, signatures=$signatures)"

public fun serialize(): ByteArray {
public fun serialize(): SerializedTransaction {
val signaturesSize = signatures.size
val signaturesLength = ShortVecEncoding.encodeLength(signaturesSize)
val bufferSize =
Expand All @@ -70,18 +70,6 @@ public data class SignedTransaction internal constructor(
out.write(signedMessage)
return out.readByteArray(bufferSize.toLong())
}

public fun validate(): Boolean {
val message = signedMessage
val messageLength = message.size
val signaturesSize = signatures.size
val signaturesLength = ShortVecEncoding.encodeLength(signaturesSize)
val signaturesSizeBytes = signaturesLength.size
val signatureSize = TweetNaCl.Signature.SIGNATURE_BYTES
val signatureSizeBytes = ShortVecEncoding.encodeLength(signatureSize)
val signatureSizeBytesLength = signatureSizeBytes.size
val expectedSize =
messageLength + signaturesSizeBytes + signaturesSize * (signatureSize + signatureSizeBytesLength)
return expectedSize == serialize().size
}
}

public typealias SerializedTransaction = ByteArray

0 comments on commit 62e6a8e

Please sign in to comment.