Masking and the Use of XOR for Encryption and Decryption

OP_DUP OP_HASH256 ⟨ℎ(𝑆1 )⟩ OP_EQUALVERIFY ⟨ℎ(𝑃𝐵)⨁𝑆1⟩ OP_XOR OP_SWAP OP_DUP OP_HASH256 OP_ROT OP_EQUALVERIFY OP_CHECKSIG
<SigP_B> <P_B> <S_1>

Key Derivation Schemes

While Bitcoin has standardized key derivation around the BIP32 standard, there are many downsides to the approach. A future article will talk about these downsides, but the important thing to note is that BIP32 is not the only way to have hierarchically derived keys . There are new key derivation schemes that are being created for BSV, and one such scheme involves utilizing a hash chain and XOR. Note in this example that this scheme is not being used necessarily for coin storage, but instead used for decryption of messages. However, it points to a wide variety of possibilities in defining new key derivation schemes.

import (
"github.com/libsv/go-bk/bec"
"github.com/libsv/go-bk/crypto"
)
func DeriveNKeysFromMaster(n int, masterSecretKey *bec.PrivateKey) ([]*bec.PrivateKey) {
matrix := make([]*bec.PrivateKey, n)
secretKey := masterSecretKey
for i := 0; i < n; i++ {
secretKey, _ := DeriveNextKey(masterSecretKey, secretKey)
matrix = append(matrix, secretKey)
}
return matrix
}
func DeriveNextKey(masterKey, secretKey *bec.PrivateKey) (*bec.PrivateKey) {
curve := bec.S256()
secretKeyBytes := secretKey.Serialise()
masterKeyBytes := masterKey.Serialise()
secretHash := crypto.Sha256(secretKeyBytes)
newKeyBytes := make([]byte, len(masterKeyBytes))
for i := range secretKeyBytes {
newKeyBytes[i] = masterKeyBytes[i] ^ secretHash[i]
}
key, _ := bec.PrivKeyFromBytes(curve, newKeyBytes)
return key
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Murray Distributed Technologies

Murray Distributed Technologies

Building the future of online reviews powered by blockchain technology at britevue.com