Cypherock Interview Experience for SDE Internship
Last Updated :
05 Sep, 2022
The following assessments are for the Cypherrock SDE Intern role. Cypherrock is a company specializing in hardware wallets with advanced backup and recovery capabilities.
Task 1: Implement Shamir Secret Sharing Algorithm using C.
Task 2: Compile the crypto library in Trezor firmware using Make.
Task 3: Calculate a BIP39 Seed using 24 bip mnemonics.
Solution: The algorithms in the BIP39 base file from Trezor firmware are to be used.
Task 4: Derive public key, private key, chain node, and receiver-change address for Bitcoin Testnet for derivation path m/44’/1’/0’/0/.
- Derive address from public and private from mnemonics
- The first node derived is the master node
For the master node, the index is 0000000
For the purpose node, we have to pass the index as 8000002C
For coin => index => 8000001 (testnet)
For account node => 00000000
Chain node :
* 00000001 (change address node)
* 00000000 (recieve address node)
Solution: The algorithms in the BIP39 and BIP32 base files from Trezor firmware are to be used.
Task 5: Sign an unsigned bitcoin testnet transaction.
Solution: The algorithms in the BIP32, BIP39, ecdsa, btc, and secp256k1 base files from Trezor firmware are to be used.
- Generate unsigned trans using the extended public key of the account node
- Complete byte_array_to_unsigned_txn() to fill the unsigned txn structUse malloc for input and output struct inside unsigned_strcut
- Complete serialize_unsigned_txn_to_sign() func to generate the serializes unsigned txn to sign corresponding to an input
- Use sha256_raw to generate a double hash of the serialize unsigned transaction (call the func twice .) (next time kind of recursive)
- Use ecdsa_sign_digest() to genrate R and S values using a private key corresonding to the input (88thline)
- Generate script_sig using ecdsa_sig_to_der() (klmoney article)
- Replace script sig with the script public key for each input inside the unsigned txn key to fill the signed txn strcut (70 lines)
Task 6: Sign a raw Ethereum (Ropsten) transaction
- Search for how Ethereum address is generated from the public key
- Convert signed txn from my ether wallet to unsigned txn
- Code for RLP encoding
- Hash the unsigned txn
- Sign the digest using the private key
- Generate V using
- Create RLP encoded signed txn from the derived R and S values
- Broadcast the signed txn using ethers scan
Transaction Details :
{
"nonce": "0x02",
"gasLimit": "0x5208",
"gasPrice": "0x77359400",
"to": "0xc0095a58489ba23cb5c6808dc0bbbf1cdca32aca",
"value": "2c68af0bb140000",
"data": "0x",
"chainId": 3
}
Solution: The algorithms in the rlp, utils, sha3, and secp256k1 base files from Trezor firmware are to be used.
Share your thoughts in the comments
Please Login to comment...