-
Notifications
You must be signed in to change notification settings - Fork 988
/
Copy pathStrKey.h
40 lines (32 loc) · 1.13 KB
/
StrKey.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
// Copyright 2014 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#include "ByteSlice.h"
#include <string>
namespace stellar
{
struct SecretValue;
namespace strKey
{
enum StrKeyVersionByte : uint8_t
{
// version bytes - 5 bits only
STRKEY_PUBKEY_ED25519 = 6, // 'G'
STRKEY_SIGNED_PAYLOAD_ED25519 = 15, // 'P'
STRKEY_SEED_ED25519 = 18, // 'S'
STRKEY_PRE_AUTH_TX = 19, // 'T'
STRKEY_HASH_X = 23, // 'X'
STRKEY_MUXED_ACCOUNT_ED25519 = 12, // 'M'
STRKEY_CONTRACT = 2, // 'C'
};
// Encode a version byte and ByteSlice into StrKey
SecretValue toStrKey(uint8_t ver, ByteSlice const& bin);
// computes the size of the StrKey that would result from encoding
// a ByteSlice of dataSize bytes
size_t getStrKeySize(size_t dataSize);
// returns true if the strKey could be decoded
bool fromStrKey(std::string const& strKey, uint8_t& outVersion,
std::vector<uint8_t>& decoded);
}
}