Skip to content

sgns::crypto

Namespaces

Name
sgns::crypto::bip39
sgns::crypto::store
sgns::crypto::key_types
sgns::crypto::constants
sgns::crypto::secp256k1

Classes

Name
class sgns::crypto::Bip39Provider
Interface for creating BIP-39 entropy and seeds from mnemonic wordlists.
class sgns::crypto::Bip39ProviderImpl
class sgns::crypto::CryptoStore
class sgns::crypto::CryptoStoreImpl
class sgns::crypto::ED25519ProviderImpl
class sgns::crypto::ED25519Provider
struct sgns::crypto::ED25519Keypair
class sgns::crypto::Hasher
class sgns::crypto::HasherImpl
class sgns::crypto::Pbkdf2ProviderImpl
class sgns::crypto::Pbkdf2Provider
Interface for PBKDF2 key derivation.
class sgns::crypto::Secp256k1ProviderImpl
class sgns::crypto::Secp256k1Provider
Interface for secp256k1 public key recovery.
class sgns::crypto::SR25519ProviderImpl
class sgns::crypto::SR25519Provider
struct sgns::crypto::VRFOutput
struct sgns::crypto::VRFVerifyOutput
struct sgns::crypto::SR25519Keypair
class sgns::crypto::VRFProviderImpl
class sgns::crypto::VRFProvider

Types

Name
enum class CryptoStoreError
enum class KeyTypeError
enum class ED25519ProviderError
enum class Pbkdf2ProviderError
enum class Secp256k1ProviderError
enum class SR25519ProviderError
using boost::filesystem::directory_iterator DirectoryIterator
using uint32_t KeyTypeId
Key type identifier.
using base::Blob< constants::ed25519::PRIVKEY_SIZE > ED25519PrivateKey
using base::Blob< constants::ed25519::PUBKEY_SIZE > ED25519PublicKey
using base::Blob< constants::ed25519::SIGNATURE_SIZE > ED25519Signature
using base::Blob< constants::ed25519::SEED_SIZE > ED25519Seed
using libp2p::crypto::random::RandomGenerator RandomGenerator
using libp2p::crypto::random::CSPRNG CSPRNG
using libp2p::crypto::random::BoostRandomGenerator BoostRandomGenerator
using std::array< uint8_t, constants::sr25519::vrf::OUTPUT_SIZE > VRFPreOutput
using boost::multiprecision::uint128_t VRFThreshold
using std::array< uint8_t, constants::sr25519::vrf::PROOF_SIZE > VRFProof
using base::Blob< constants::sr25519::SECRET_SIZE > SR25519SecretKey
using base::Blob< constants::sr25519::PUBLIC_SIZE > SR25519PublicKey
using base::Blob< constants::sr25519::SEED_SIZE > SR25519Seed
using base::Blob< constants::sr25519::SIGNATURE_SIZE > SR25519Signature
using Blob< 16 > Hash128
using Blob< 32 > Hash256
using Blob< 8 > Hash64

Functions

Name
std::ostream & operator<<(std::ostream & out, const CryptoStoreError & test_struct)
bool isSupportedKeyType(KeyTypeId k)
checks whether key type value is supported
std::string decodeKeyTypeId(KeyTypeId param)
makes string representation of KeyTypeId
outcome::result< int > validateRecoveryId(int v)
base::Hash256 sha256(std::string_view input)
base::Hash256 sha256(gsl::span< const uint8_t > input)
std::vector< uint8_t > sha256(const void * data, size_t dataSize)
template <class Stream ,typename =std::enable_if_t>
Stream &
operator<<(Stream & s, const VRFOutput & o)
outputs object of type VRFOutput to stream
template <class Stream ,typename =std::enable_if_t>
Stream &
operator>>(Stream & s, VRFOutput & o)
decodes object of type VRFOutput from stream
void make_twox64(const uint8_t * in, uint32_t len, uint8_t * out)
base::Hash64 make_twox64(gsl::span< const uint8_t > buf)
void make_twox128(const uint8_t * in, uint32_t len, uint8_t * out)
base::Hash128 make_twox128(gsl::span< const uint8_t > buf)
void make_twox256(const uint8_t * in, uint32_t len, uint8_t * out)
base::Hash256 make_twox256(gsl::span< const uint8_t > buf)

Types Documentation

enum CryptoStoreError

Enumerator Value Description
WRONG_KEYFILE_NAME 1
UNSUPPORTED_KEY_TYPE
UNSUPPORTED_CRYPTO_TYPE
NOT_REGULAR_FILE
FAILED_OPEN_FILE
FILE_DOESNT_EXIST
INVALID_FILE_FORMAT
INCONSISTENT_KEYFILE
WRONG_SEED_SIZE
KEY_NOT_FOUND
KEYS_PATH_IS_NOT_DIRECTORY
FAILED_CREATE_KEYS_DIRECTORY

enum KeyTypeError

Enumerator Value Description
UNSUPPORTED_KEY_TYPE 1
UNSUPPORTED_KEY_TYPE_ID

enum ED25519ProviderError

Enumerator Value Description
FAILED_GENERATE_KEYPAIR 1
SIGN_UNKNOWN_ERROR
VERIFY_UNKNOWN_ERROR

enum Pbkdf2ProviderError

Enumerator Value Description
KEY_DERIVATION_FAILED 1

enum Secp256k1ProviderError

Enumerator Value Description
INVALID_ARGUMENT 1
INVALID_V_VALUE
INVALID_R_OR_S_VALUE
INVALID_SIGNATURE
RECOVERY_FAILED

enum SR25519ProviderError

Enumerator Value Description
SIGN_UNKNOWN_ERROR 1
VERIFY_UNKNOWN_ERROR

sr25519 provider error codes

using DirectoryIterator

using sgns::crypto::DirectoryIterator = boost::filesystem::directory_iterator;

using KeyTypeId

using sgns::crypto::KeyTypeId = uint32_t;

Key type identifier.

using ED25519PrivateKey

using sgns::crypto::ED25519PrivateKey = base::Blob<constants::ed25519::PRIVKEY_SIZE>;

using ED25519PublicKey

using sgns::crypto::ED25519PublicKey = base::Blob<constants::ed25519::PUBKEY_SIZE>;

using ED25519Signature

using sgns::crypto::ED25519Signature = base::Blob<constants::ed25519::SIGNATURE_SIZE>;

using ED25519Seed

using sgns::crypto::ED25519Seed = base::Blob<constants::ed25519::SEED_SIZE>;

using RandomGenerator

using sgns::crypto::RandomGenerator = libp2p::crypto::random::RandomGenerator;

using CSPRNG

using sgns::crypto::CSPRNG = libp2p::crypto::random::CSPRNG;

using BoostRandomGenerator

using sgns::crypto::BoostRandomGenerator = libp2p::crypto::random::BoostRandomGenerator;

using VRFPreOutput

using sgns::crypto::VRFPreOutput = 
std::array<uint8_t, constants::sr25519::vrf::OUTPUT_SIZE>;

using VRFThreshold

using sgns::crypto::VRFThreshold = boost::multiprecision::uint128_t;

using VRFProof

using sgns::crypto::VRFProof = std::array<uint8_t, constants::sr25519::vrf::PROOF_SIZE>;

using SR25519SecretKey

using sgns::crypto::SR25519SecretKey = base::Blob<constants::sr25519::SECRET_SIZE>;

using SR25519PublicKey

using sgns::crypto::SR25519PublicKey = base::Blob<constants::sr25519::PUBLIC_SIZE>;

using SR25519Seed

using sgns::crypto::SR25519Seed = base::Blob<constants::sr25519::SEED_SIZE>;

using SR25519Signature

using sgns::crypto::SR25519Signature = base::Blob<constants::sr25519::SIGNATURE_SIZE>;

using Hash128

using sgns::base::Hash128 = Blob<16>;

using Hash256

using sgns::base::Hash256 = Blob<32>;

using Hash64

using sgns::base::Hash64 = Blob<8>;

Functions Documentation

function operator<<

inline std::ostream & operator<<(
    std::ostream & out,
    const CryptoStoreError & test_struct
)

function isSupportedKeyType

bool isSupportedKeyType(
    KeyTypeId k
)

checks whether key type value is supported

Parameters:

  • k key type value

Return: true if supported, false otherwise

function decodeKeyTypeId

std::string decodeKeyTypeId(
    KeyTypeId param
)

makes string representation of KeyTypeId

Parameters:

  • param param key type

Return: string representation of key type value

function validateRecoveryId

outcome::result< int > validateRecoveryId(
    int v
)

function sha256

base::Hash256 sha256(
    std::string_view input
)

Parameters:

  • input to be hashed

Return: hashed bytes

Take a SHA-256 hash from string

function sha256

base::Hash256 sha256(
    gsl::span< const uint8_t > input
)

Parameters:

  • input to be hashed

Return: hashed bytes

Take a SHA-256 hash from bytes

function sha256

std::vector< uint8_t > sha256(
    const void * data,
    size_t dataSize
)

function operator<<

template <class Stream ,
typename  =std::enable_if_t<Stream::is_encoder_stream>>
Stream & operator<<(
    Stream & s,
    const VRFOutput & o
)

outputs object of type VRFOutput to stream

Parameters:

  • s stream reference
  • o value to output

Template Parameters:

  • Stream output stream type

Return: reference to stream

function operator>>

template <class Stream ,
typename  =std::enable_if_t<Stream::is_decoder_stream>>
Stream & operator>>(
    Stream & s,
    VRFOutput & o
)

decodes object of type VRFOutput from stream

Parameters:

  • s stream reference
  • o value to output

Template Parameters:

  • Stream input stream type

Return: reference to stream

function make_twox64

void make_twox64(
    const uint8_t * in,
    uint32_t len,
    uint8_t * out
)

function make_twox64

base::Hash64 make_twox64(
    gsl::span< const uint8_t > buf
)

function make_twox128

void make_twox128(
    const uint8_t * in,
    uint32_t len,
    uint8_t * out
)

function make_twox128

base::Hash128 make_twox128(
    gsl::span< const uint8_t > buf
)

function make_twox256

void make_twox256(
    const uint8_t * in,
    uint32_t len,
    uint8_t * out
)

function make_twox256

base::Hash256 make_twox256(
    gsl::span< const uint8_t > buf
)

Updated on 2026-03-04 at 13:10:43 -0800