Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::em::signature_shim Struct Reference

#include <elliptic_em.hpp>

Inheritance diagram for fc::em::signature_shim:
Collaboration diagram for fc::em::signature_shim:

Public Types

using public_key_type = public_key_shim
 
- Public Types inherited from fc::crypto::shim< compact_signature >
using data_type
 

Public Member Functions

public_key_type recover (const sha256 &digest, bool check_canonical) const
 
- Public Member Functions inherited from fc::crypto::shim< compact_signature >
 shim ()
 
 shim (data_type &&data)
 
 shim (const data_type &data)
 
const data_typeserialize () const
 

Additional Inherited Members

- Public Attributes inherited from fc::crypto::shim< compact_signature >
data_type _data
 

Detailed Description

Definition at line 161 of file elliptic_em.hpp.

Member Typedef Documentation

◆ public_key_type

Member Function Documentation

◆ recover()

public_key_type fc::em::signature_shim::recover ( const sha256 & digest,
bool check_canonical ) const
inline

Definition at line 165 of file elliptic_em.hpp.

165 {
166 // "x19Ethereum Signed Message:\n" is the header used by the `eth_sign` RPC call. We have converted the string to its hex value to save a step.
167 // std::string erc155_message_prefix = "19457468657265756d205369676e6564204d6573736167653a0a3332";
168 uint8_t eth_prefix[28] = {
169 25, 69, 116, 104, 101, 114, 101,
170 117, 109, 32, 83, 105, 103, 110,
171 101, 100, 32, 77, 101, 115, 115,
172 97, 103, 101, 58, 10, 51, 50
173 };
174 // Hash (keccak256) the msg string
175
176 // unsigned char msg_digest_result = digest.data();
177 unsigned char eth_prefixed_msg_raw[28 + 32];
178 std::copy(std::begin(eth_prefix), std::end(eth_prefix), std::begin(eth_prefixed_msg_raw));
179 std::copy((unsigned char*) digest.data(), (unsigned char*) digest.data() + 32, std::begin(eth_prefixed_msg_raw) + 28);
180
181 SHA3_CTX msg_ctx;
182 keccak_init(&msg_ctx);
183 keccak_update(&msg_ctx, eth_prefixed_msg_raw, 60);
184
185 // Hash the newly created raw message.
186 unsigned char msg_digest_result[32];
187 keccak_final(&msg_ctx, msg_digest_result);
188
189 // sha256 msg_digest
190 return public_key_type(public_key(_data, msg_digest_result, false).serialize());
191 }
const char * data() const
Definition sha256.cpp:31
void keccak_init(SHA3_CTX *ctx)
Definition keccak256.cpp:75
void keccak_update(SHA3_CTX *ctx, const unsigned char *msg, uint16_t size)
void keccak_final(SHA3_CTX *ctx, unsigned char *result)
fc::sha256 digest(const T &value)
Definition digest.hpp:9
unsigned char uint8_t
Definition stdint.h:124
const data_type & serialize() const
Definition common.hpp:188
public_key_shim public_key_type
Here is the call graph for this function:

The documentation for this struct was generated from the following file: