January 19, 2023Ardan Labs
From the Ardan Community
Introduction Table tests are a great way to test different inputs and associated outputs for a function in Go. To write a table test, you define a slice of some data struct with fields of the input data you’ll need and the expected outcome. Then you can loop through this slice and pass the data stored for each element to your function. One disadvantage of table tests is as the data set in your slice grows, the harder it is to find the failing case.
Continue reading January 17, 2023Ardan Labs
From the Ardan Community
Introduction When an API requires implementation details from the user, many developers use an interface for help. However, another way to allow developers to provide implementation details for an API is to accept a function instead. Go supports declaring function types which can be used to define a contract similar to how interfaces define a contract. A good example of an API that uses functions over an interface is the HTTP package.
Continue reading January 17, 2023Ardan Labs
From the Ardan Community
Introduction In episode 15, Bill architected a solution to ensure all the users on his blockchain were given a unique identifier. His approach consisted of essentially leveraging the randomness of a user’s private key to ensure each identifier is unique. A disadvantage Bill pointed out with this is that a user may forget their private key and ultimately lose access to their account. To circumvent this issue, Bill proposed the usage of a mnemonic, that is composed of 12 to 24 words, to act as the private key since it’s simpler to keep track of and hard to guess.
Continue reading January 12, 2023Ardan Labs
From the Ardan Community
Introduction Google developed Go to be an alternative to C++ with the internet and scale in mind. Go’s toolchain automates tasks that are easily overlooked, and amongst those tasks is generating documentation. Go has the ability to generate documentation based on comments written in your source code. As the end user, you have the choice to view this documentation in your terminal or, if your code is publicly accessible, on pkg.
Continue reading January 12, 2023Ardan Labs
From the Ardan Community
Introduction In episode 14, Bill architected a solution to digitally sign the transactions on his blockchain. His solution retrieved the private key by : loading private key data from disk, parsing the key data and returning the ECDSA private key. The private key is then used to generate the signature of a transaction. While writing the code to perform this functionality, Bill highlighted how a blockchain node can use a transaction’s signature to extrapolate the public key.
Continue reading January 11, 2023Ardan Labs
From the Ardan Community
Introduction In episode 13, Bill discussed the idea of adding salt to a hash and how modern crypto-currency blockchains use it to better interpret requests sent to nodes. He continued by defining a function called stamp that embeds a salt within a hash. While writing the function, Bill stated that he would use keccak256 as it’s the same algorithm used by Ethereum to generate hash values. Bill will use the APIs provided with Go Ethereum to generate a keccak256 hash.
Continue reading January 11, 2023Ardan Labs
From the Ardan Community
Introduction In episode 12, Bill laid out his strategy to handle data hashing on his blockchain. The first step he took was to create a package to handle the cryptographical aspects of his blockchain. After that, he wrote a hash function that met the requirements outlined in his strategy. This function took transaction data as a parameter and returned a hexadecimal representation of the hash. To implement this function, Bill imported packages from the Go standard library and Ethereum API.
Continue reading January 4, 2023Ardan Labs
From the Ardan Community
Introduction In episode 11, Bill highlighted the issue of identity verification and provided a solution to this problem. The solution proposed was to cryptographically sign a transaction to verify its authenticity. Bill chose to implement a solution making use of the Elliptic Curve Digital Signature Algorithm (ECDSA) as the public key can be extracted from a signature. Although a small distinction, the ability to re-compute a public key is essential in a decentralized and distributed environment.
Continue reading January 3, 2023Ardan Labs
From the Ardan Community
Introduction In episode 10, Bill dove into the technical implementation of his genesis record and defined a custom Go type representing the record. While doing so, he provided an in-depth look at the reasoning behind the fields he included.. After declaring this type, Bill wrote a function that loads the genesis record from disk and onto memory. His function will use the standard library encoding/json package to load JSON data from a hard-coded file path.
Continue reading January 3, 2023Ardan Labs
From the Ardan Community
Introduction In episode 9, Bill introduced the idea of the genesis record and its role in his blockchain. As a recap, the genesis record will be used to customize the settings of his blockchain. The approach Bill takes here is similar to how Ethereum operates because he is storing the record in JSON format.
In this video, Bill starts by defining the Go types his blockchain will use. The first type he defines will represent the genesis record.
Continue reading