Generating a wallet
In AIRE, each student or entity is assigned a unique wallet address. This wallet is automatically generated using the student data (ex: Microsoft account, Student number) or it can be manually created by the student/faculty. But a wallet doesn't really hold any funds/university tokens. Those university tokens are stored on a subsection of our network, isolated from other tokens from other universities.
The wallet is used to verify the identity of the student/entity to grant access to the university tokens. Since a wallet can be generated without any network call or internet connection, it is mandatory to assiociate the wallet with an account.
Generating a wallet is in theory very simple to generate as it's pretty much just a hash of the student data. What we call a wallet is simply a 64-bit number that can be used to to generate a keypair.
Note: The wallet is not a public key. It's a private key.
Algorithm to generate a wallet
- Generate 32 random 8-bit unsigned integers. (In JavaScript, we can use a Uint8Array of length 64)
If you want to use data to generate a wallet, you can use the SHA-256 algorithm to generate an array of 32 8-bit unsigned integers with the hash of the data.
- Use any Ed25519 algorithm to generate a public key and a private key from the 32 random 8-bit unsigned integers (also known as a seed).
Example using JavaScript:
import nacl from 'tweetnacl';
const data = new TextEncoder().encode("<string containing student data>");const hashBuffer = await crypto.subtle.digest('SHA-256', data);const seed = new Uint8Array(hashBuffer);
const { publicKey, secretKey } = nacl.sign.keyPair.fromSeed(seed);
Using our API to generate a wallet
To make this process easier, we made an API endpoint that generates a wallet for you.
/wallet-gen
When you call this endpoint, you will get a JSON response with the public key and the private key. If you send a GET request, the keypair will be generated using random data. If you send a POST request, the keypair will be generated from this data. It can be any kind of data, but it's recommended to use a JSON object with multiple unique fields such as the student number, student name, etc.
Make sure to include non-public data such as their card number or anything else, as anyone with the data you'll send will be able to generate the same wallet, and therefore gain access to the student's funds.