In Zecrey-Marketplace-SDK, in order to make it easy for developers to register and send transactions, the private key signing process is encapsulated inside the SDK methods. Thus, developers do not need to understand the principle and process of signing, just use the SDK-client to make method calls to complete the required functions.
In order to provide developers with a deeper understanding of the process of signing transactions by the SDK, in the following section, we will explain the process of user signature transactions and related function methods. This section is only intended to give developers a deeper understanding of Zecrey and Zecrey SDK.
Due to the difference in the signature algorithms (ecdsa/eddsa) between L1 and L2 account systems, they use different private keys for transaction signatures:
A transaction occurring on L1 requires the transaction to be signed on L1. For example, depositing assets from an L1 wallet to an L2 wallet uses the L1 private key.
Transactions occurring on Zecrey (L2) require the transaction to be signed on L2. For example, all transactions initiated on L2 need to be signed using L2's private key.
Note that the L2 private key is derived from the L1 private key signature, which means that there is a one-to-one correspondence between the L1 and L2 private keys. If you generate your own Zecrey (L2) private key, you can make it permanent to avoid repeated operations. There will be no need to regenerate the seed with the private key of L1 in the future.
The following examples show how to use the SDK for account creation, L2 private key generation and transaction signature respectively.
Create an account:
Use the client to generate an L1 account and private key, then generate an L2 seed (private key) and public key