Created
October 15, 2019 08:36
-
-
Save hewigovens/6f13d532bd7c385080b951cc497bd5cd to your computer and use it in GitHub Desktop.
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
func testKusama() { | |
let key = PrivateKey(data: Data(hexString: "0x85fca134b3fe3fd523d8b528608d803890e26c93c86dc3d97b8d59c7b3540c97")!)! | |
let pubkey = key.getPublicKeyEd25519() | |
print("public key", pubkey.data.hexString) | |
let preimage = Data([0x2]) + pubkey.data | |
print("preimage", preimage.hexString) | |
let hash = Hash.blake2b(data: "SS58PRE".data(using: .utf8)! + preimage, size: 64) | |
print("blake2b hash", hash.hexString) | |
let decoded = Base58.decodeNoCheck(string: "HewiDTQv92L2bVtkziZC8ASxrFUxr6ajQ62RXAnwQ8FDVmg")! | |
let checksum = hash[0..<2] | |
XCTAssertEqual(preimage + checksum, decoded) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment