Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4d324084e8 | |||
| eae8cd24f4 | |||
| 0529c28563 | |||
| 3e7f4e7254 | |||
| 3be71635ac | |||
| e6c412e2c3 | |||
| 960076f4ce | |||
| 7d12b93e7e |
+3
-3
@@ -14,9 +14,9 @@ endif()
|
||||
project(cdt)
|
||||
|
||||
set(VERSION_MAJOR 4)
|
||||
set(VERSION_MINOR 0)
|
||||
set(VERSION_PATCH 1)
|
||||
set(VERSION_SUFFIX "rc1")
|
||||
set(VERSION_MINOR 2)
|
||||
set(VERSION_PATCH 0)
|
||||
# set(VERSION_SUFFIX "rc1")
|
||||
|
||||
if (VERSION_SUFFIX)
|
||||
set(VERSION_FULL "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${VERSION_SUFFIX}")
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
FROM ubuntu:latest
|
||||
|
||||
WORKDIR /workdir
|
||||
|
||||
COPY build/cdt_*.deb /workdir
|
||||
|
||||
RUN apt-get update && apt-get install -y wget cmake build-essential g++ libboost-all-dev libz3-dev && \
|
||||
apt install ./cdt_*.deb -y && \
|
||||
rm cdt_*.deb
|
||||
@@ -232,6 +232,41 @@ int recover_key( const struct capi_checksum256* digest, const char* sig, size_t
|
||||
__attribute__((eosio_wasm_import))
|
||||
void assert_recover_key( const struct capi_checksum256* digest, const char* sig, size_t siglen, const char* pub, size_t publen );
|
||||
|
||||
/**
|
||||
* Tests a signature against a hash, verifies the recovered public key matches the expected one,
|
||||
* and checks that this public key belongs to the specified account permission.
|
||||
*
|
||||
* @ingroup crypto
|
||||
* @param digest - Pointer to the digest/hash of the message that was signed
|
||||
* @param sig - Pointer to the signature
|
||||
* @param siglen - Length of the signature
|
||||
* @param pub - Pointer to the expected public key
|
||||
* @param publen - Length of the expected public key
|
||||
* @param account - The account name to verify key ownership
|
||||
* @param permission - The permission name to check (e.g., active, owner)
|
||||
*
|
||||
* @pre `digest` is a valid pointer to a `capi_checksum256` struct
|
||||
* @pre `sig` is a valid pointer to a buffer containing the signature
|
||||
* @pre `pub` is a valid pointer to a buffer containing the expected public key
|
||||
*
|
||||
* @post Throws if signature is invalid, key doesn't match, or key doesn't belong to account permission
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* capi_checksum256 digest;
|
||||
* char sig[65];
|
||||
* size_t siglen = 65;
|
||||
* char pub[34];
|
||||
* size_t publen = 34;
|
||||
* capi_name account = N(myaccount);
|
||||
* capi_name permission = N(active);
|
||||
* assert_recover_key_account( &digest, sig, siglen, pub, publen, account, permission );
|
||||
* // If all checks pass, code continues here
|
||||
* @endcode
|
||||
*/
|
||||
__attribute__((eosio_wasm_import))
|
||||
void assert_recover_key_account( const struct capi_checksum256* digest, const char* sig, size_t siglen, const char* pub, size_t publen, uint64_t account, uint64_t permission );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,16 @@ extern "C" {
|
||||
* @brief Defines %C Privileged API
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the RAM usage an account
|
||||
*
|
||||
* @param account - name of the account whose resource limit to get
|
||||
* @param used_ram_bytes - pointer to `int64_t` to hold retrieved ram usage in absolute bytes
|
||||
*/
|
||||
__attribute__((eosio_wasm_import))
|
||||
void get_account_ram_usage( capi_name account, int64_t* used_ram_bytes );
|
||||
|
||||
|
||||
/**
|
||||
* Get the resource limits of an account
|
||||
*
|
||||
|
||||
@@ -12,6 +12,9 @@ namespace eosio {
|
||||
__attribute__((eosio_wasm_import))
|
||||
bool is_privileged( uint64_t account );
|
||||
|
||||
__attribute__((eosio_wasm_import))
|
||||
void get_account_ram_usage( uint64_t account, int64_t* used_ram_bytes );
|
||||
|
||||
__attribute__((eosio_wasm_import))
|
||||
void get_resource_limits( uint64_t account, int64_t* ram_bytes, int64_t* net_weight, int64_t* cpu_weight );
|
||||
|
||||
@@ -182,6 +185,19 @@ namespace eosio {
|
||||
*/
|
||||
void get_blockchain_parameters(eosio::blockchain_parameters& params);
|
||||
|
||||
|
||||
/**
|
||||
* Get the ram usage of an account
|
||||
*
|
||||
* @ingroup privileged
|
||||
* @param account - name of the account whose resource limit to get
|
||||
* @param used_ram_bytes - output to hold retrieved ram usage in absolute bytes
|
||||
*/
|
||||
inline void get_account_ram_usage( name account, int64_t& used_ram_bytes ) {
|
||||
internal_use_do_not_use::get_account_ram_usage( account.value, &used_ram_bytes);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the resource limits of an account
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "fixed_bytes.hpp"
|
||||
#include "varint.hpp"
|
||||
#include "serialize.hpp"
|
||||
#include "name.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
@@ -336,4 +337,24 @@ namespace eosio {
|
||||
* @param pubkey - Public key
|
||||
*/
|
||||
void assert_recover_key( const eosio::checksum256& digest, const eosio::signature& sig, const eosio::public_key& pubkey );
|
||||
|
||||
/**
|
||||
* Tests a signature against a hash, verifies the recovered public key matches the expected one,
|
||||
* and checks that this public key belongs to the specified account permission.
|
||||
*
|
||||
* @ingroup crypto
|
||||
* @param digest - Digest of the message that was signed
|
||||
* @param sig - Signature
|
||||
* @param pubkey - Expected public key
|
||||
* @param account - The account name to verify key ownership
|
||||
* @param permission - The permission name to check (e.g., "active"_n, "owner"_n)
|
||||
*
|
||||
* @throw eosio::check will fail if:
|
||||
* - The signature is invalid
|
||||
* - The recovered key doesn't match the expected public key
|
||||
* - The account doesn't exist
|
||||
* - The permission doesn't exist for the account
|
||||
* - The public key doesn't belong to the specified account permission
|
||||
*/
|
||||
void assert_recover_key_account( const eosio::checksum256& digest, const eosio::signature& sig, const eosio::public_key& pubkey, eosio::name account, eosio::name permission );
|
||||
}
|
||||
|
||||
@@ -42,6 +42,11 @@ extern "C" {
|
||||
__attribute__((eosio_wasm_import))
|
||||
void assert_recover_key( const capi_checksum256* digest, const char* sig,
|
||||
size_t siglen, const char* pub, size_t publen );
|
||||
|
||||
__attribute__((eosio_wasm_import))
|
||||
void assert_recover_key_account( const capi_checksum256* digest, const char* sig,
|
||||
size_t siglen, const char* pub, size_t publen,
|
||||
uint64_t account, uint64_t permission );
|
||||
}
|
||||
|
||||
namespace eosio {
|
||||
@@ -131,4 +136,16 @@ namespace eosio {
|
||||
sig_data.data(), sig_data.size(),
|
||||
pubkey_data.data(), pubkey_data.size() );
|
||||
}
|
||||
|
||||
void assert_recover_key_account( const eosio::checksum256& digest, const eosio::signature& sig, const eosio::public_key& pubkey, eosio::name account, eosio::name permission ) {
|
||||
auto digest_data = digest.extract_as_byte_array();
|
||||
|
||||
auto sig_data = eosio::pack(sig);
|
||||
auto pubkey_data = eosio::pack(pubkey);
|
||||
|
||||
::assert_recover_key_account( reinterpret_cast<const capi_checksum256*>(digest_data.data()),
|
||||
sig_data.data(), sig_data.size(),
|
||||
pubkey_data.data(), pubkey_data.size(),
|
||||
account.value, permission.value );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
// Boilerplate
|
||||
using namespace eosio::native;
|
||||
extern "C" {
|
||||
void get_account_ram_usage( capi_name account, int64_t* used_ram_bytes ) {
|
||||
return intrinsics::get().call<intrinsics::get_account_ram_usage>(account, used_ram_bytes);
|
||||
}
|
||||
void get_resource_limits( capi_name account, int64_t* ram_bytes, int64_t* net_weight, int64_t* cpu_weight ) {
|
||||
return intrinsics::get().call<intrinsics::get_resource_limits>(account, ram_bytes, net_weight, cpu_weight);
|
||||
}
|
||||
@@ -235,6 +238,9 @@ extern "C" {
|
||||
int recover_key( const capi_checksum256* digest, const char* sig, size_t siglen, char* pub, size_t publen ) {
|
||||
return intrinsics::get().call<intrinsics::recover_key>(digest, sig, siglen, pub, publen);
|
||||
}
|
||||
void assert_recover_key_account( const capi_checksum256* digest, const char* sig, size_t siglen, const char* pub, size_t publen, uint64_t account, uint64_t permission ) {
|
||||
return intrinsics::get().call<intrinsics::assert_recover_key_account>(digest, sig, siglen, pub, publen, account, permission);
|
||||
}
|
||||
void assert_sha256( const char* data, uint32_t length, const capi_checksum256* hash ) {
|
||||
return intrinsics::get().call<intrinsics::assert_sha256>(data, length, hash);
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace eosio { namespace native {
|
||||
}
|
||||
|
||||
#define INTRINSICS(intrinsic_macro) \
|
||||
intrinsic_macro(get_account_ram_usage) \
|
||||
intrinsic_macro(get_resource_limits) \
|
||||
intrinsic_macro(set_resource_limits) \
|
||||
intrinsic_macro(set_proposed_producers) \
|
||||
@@ -116,6 +117,7 @@ intrinsic_macro(db_upperbound_i64) \
|
||||
intrinsic_macro(db_end_i64) \
|
||||
intrinsic_macro(assert_recover_key) \
|
||||
intrinsic_macro(recover_key) \
|
||||
intrinsic_macro(assert_recover_key_account) \
|
||||
intrinsic_macro(assert_sha256) \
|
||||
intrinsic_macro(assert_sha1) \
|
||||
intrinsic_macro(assert_sha512) \
|
||||
|
||||
Reference in New Issue
Block a user