chapter271, [SORA][SORA Network] We have implemented a latest log function.

We have implemented a latest log function.
Then, the String processing has also been adapted to the latest core.
SORA is gradually becoming a latest core. thank you so much!



chapter269, [SORA][SORA Network] We implemented the CFrimKey (Enhanced CKey).

We have been reviewed the CKey code in the latest core and we implemented the enhanced CFirmKey.


We have added enhanced random numbers(GetStrongRandBytes) for erasing used key containers, strengthening confirmation of infinite values, separating the ctx, and generating keys.

CKey: for old logic private key (base58).
CFirmKey: for latest logic private key (bech32).

SorachanCoin CFirmKey Transaction:
CKey(base58) => CKey(base58): OK
CKey(base58) => CFirmKey(bech32): OK
CFirmKey(bech32) => CKey(base58): OK
CFirmKey(bech32) => CFirmKey(bech32): OK

chapter268, [SORA][SORA Network] We implement the strong random and fixed allocator for OpenSSL

We have been ported random number processing from the latest core.


However, we have significantly fixed OpenSSL’s multithreaded support.

Bitcoin code (random.cpp):
RNGState& GetRNGState() noexcept
  // This C++11 idiom relies on the guarantee that static variable are initialized
  // on first call, even when multiple parallel calls are permitted.
  static std::vector<RNGState, secure_allocator<RNGState>> g_rng(1);
  return g_rng[0];

Static variables are called when they are used,
so this implementation enables multithreading there when OpenSSL was used in this class.

Since this class is responsible for OpenSSL random numbers,
if processing other than random numbers is executed by OpenSSL before random number processing,
a mutex for thread control has NOT been generated,
so there is a possibility of conflicts in multiple threads.

SorachanCoin, OpenSSL startup and new delete Secure allocator:
static unsigned char g_dummy[10] = {0};
class OpenSSL_startup {
  OpenSSL_startup() noexcept {
    unsigned char ch[32] = {0};
    CSHA512 hasher;
    hasher.Write(ch, sizeof(ch));
    RNGState &obj = RNGState::GetRNGState(); // generate RNGState
    obj.MixExtract(g_dummy, sizeof(g_dummy)/sizeof(char) – 1, std::move(hasher), false);
    g_dummy[9] = ‘\0’;
    DEBUG_LSYNC_CS(“called OpenSSL_startup()”);
OpenSSL_startup dummy_openssl;

void *operator new(size_t size, const std::nothrow_t &) noexcept {
  DEBUG_LSYNC_CS(“called GetRNGState() new operator”);
  unsigned char *p = (unsigned char *)::malloc(size + sizeof(size_t));
  if(! p) return nullptr;
  *((size_t *)p) = size + sizeof(size_t);
  return (void *)(p + sizeof(size_t));
void *operator new(size_t size)=delete;
void *operator new[](size_t size)=delete;
void operator delete(void *p) noexcept {
  DEBUG_LSYNC_CS(“called GetRNGState() delete operator”);
  unsigned char *head = (unsigned char *)p – sizeof(size_t);
  const size_t size = *((size_t *)head);
  cleanse::OPENSSL_cleanse(head, size);
void operator delete[](void *p)=delete;

static RNGState &GetRNGState() noexcept {
  class manage {
    RNGState *m_ptr;
    manage() : m_ptr(nullptr) {
    m_ptr = new (std::nothrow) RNGState;
    if(! m_ptr)
      throw std::runtime_error(“Out of memory: RNGState manage()”);
    ~manage() {
      if(m_ptr) delete m_ptr;
    RNGState &get() noexcept {
      return *m_ptr;

  // This C++11 idiom relies on the guarantee that static variable are initialized
  // on first call, even when multiple parallel calls are permitted.
  DEBUG_LSYNC_CS(“called GetRNGState()”);
  static manage obj;
  return obj.get();

Init mutex [RNGState()]:
// Init OpenSSL library multithreading support
DEBUG_LSYNC_CS(“called RNGState() 2”);
m_pmutexOpenSSL = (Mutex *)OPENSSL_malloc(::CRYPTO_num_locks() * sizeof(Mutex));
if(! m_pmutexOpenSSL)
  throw std::runtime_error(“Out of memory: Init OpenSSL library multithreading support”);
for(int i=0; i<::CRYPTO_num_locks(); ++i)
  new(m_pmutexOpenSSL + i) Mutex;

release mutex[~RNGState()]:
DEBUG_LSYNC_CS(“called ~RNGState()”);
// Securely erase the memory used by the OpenSSL PRNG
// Shutdown OpenSSL library multithreading support
for (int i=0; i<::CRYPTO_num_locks(); ++i)
  (m_pmutexOpenSSL + i)->~Mutex();
cleanse::OPENSSL_cleanse(m_pmutexOpenSSL, ::CRYPTO_num_locks() * sizeof(Mutex));

Now you anywhere can use the OpenSSL functions
you want to keep during the porting from old core.

Of course, we will aim to emerge from OpenSSL,
but we may that C++23 will be required.


chapter267, [SORA][SORA Network][BIP66] We conformed BIP66 and enabled ENDOMORPHISM in pubkey.

The develop branch now supports BIP66.
In addition, since the DER signature has been became strict, on effect that with the conventional OpenSSL verification became result in “hybrid”, these will work without problems in a wide range of circumstance.

In addition, we had been enabled ENDOMORPHISM. thanks.


chapter266, [SORA][SORA Network] [fixed] prevent to accept in the pubkey that is infinity by the secp256k1_ge.

We are implementing BIP32 and BIP66.
Therefore, we will implement to use OpenSSL for random wallet and secp256k1 (libsecp256k1) for HD wallet.

This leaves you with the option of using a random wallet if you don’t want to be affected by the stricter DER signatures.
Certainly, for PoW reward, a random wallet is enough.

By the way, we implemented secp256k1 in CPubKey, and there was something that was worried about.
When secp256k1_ge is infinity, error checking is no opetrate and that bytes array is accepted as a public key as it is.
So we put in some error handling and put in the code to disable.



chapter264, [SORA][SORA Network] SorachanCoin: Improvement security of SecureString.

Hello friends!
We will soon complete the verification of new features. (e.g. getblockqhash)
We would like to go with the release …..
But before that, we found one problem that have been from before SORA released.

In the process of the SecureString, we found a problem that the passphrase remains in “plain text” in the object before passing.
Therefore, we have improved the SecureString so that the “plain text” passphrase is cleaned by “::OpenSSL_cleanse” in the functor method.

allocator.h (class SecureString)

eg usage: SecureString functor.

eg usage: SecureString functor QString.

chapter263, [SORA][SORA Network] JSON and BitcoinRPC processing have been improved to “noexcept”.

JSON and BitcoinRPC processing have been improved to “noexcept”.

About an errors,
JSON is “json_flags”, BitcoinRPC is “CBitrpcData” as request packet.

In addition, ….. although some are not yet “noexcept”,
we will improve for RPC immediately. thanks.

json_spirit noexcept version

boost-noexcept (

BitcoinRPC noexcept version

chapter262, [SORA][SORA Network] We have removed an exception handler from the JSON parser.

We have removed an exception handler from the JSON parser.

We have defined “json_spirit :: json_flags” and improved them so that errors can be handled on the place.
There is no exception mechanism, making to lighter and more comfortable.

We will update Github as soon as the verification is completed. thanks.

chapter261, [SORA][SORA Network] No exception? so, we can get rid of own exceptions, but what about Boost library exceptions?

Obviously, the process of removing exceptions are NOT just about adding “noexcept” to members.
If so, it will be “throw” without an exception mechanism and the program will crash.
We improve codes, the stack is properly returned to the current position and error handler is executed.
Regarding Boost library too, cut off exception, we have been confirmed that the stack can be returned without any problem, and that error handler can be done by “boolean” or “request packet” method. Please be assure!