crypto-go

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2025 License: MIT Imports: 13 Imported by: 0

README

Teste Aprendendo Conceitos de Blockchain

Made from scratch, generic propose, production ready blockchain for uses like office files, criptocurrency Build using TDD

Test Coverage

Coverage

Features

  • [v] Server
    • Creating blocks
  • Block
    • Block's hash
    • Test
  • Transaction
    • Transaction list Hash
    • Test
  • Key
  • Transport => tcp, udp,
    • Local transport layer
  • Crypto Keypairs and signature
  • Block Signing
  • Blockchain struct
  • Storage (memory storage)
  • Transaction Encoding/Decoding
  • Block Encoding/Decoding

Todos

Improvements and fixes that can be implemented

  • Add a database or a better storage method to store transactions and block data

Types

  • Hash
type Hash [32]uint8
type Address [20]uint8
Mistakes to remember

On the struct Transaction on Signing the transaction the object was missing the value of the transaction's Signature, returnning a null value

func TestSignTransaction(t *testing.T) {
	privateKey := crypto.GeneratePrivateKey()

	tx := &Transaction{
		Data: []byte("foo bar baz"),
	}

	assert.Nil(t, tx.Sign(privateKey))
	assert.NotNil(t, tx.Signature) // FAIL

}

Beacuse of the method signatue (tx T) insted of (tx *T), the object was missing the reference

old :

func (tx Transaction) Sign(privKey crypto.PrivateKey) error {

fixed:

func (tx *Transaction) Sign(privKey crypto.PrivateKey) error {

Instalação

Para instalar as dependências do projeto, execute:

go mod tidy

Para executar o projeto

make run

Como Contribuir

  1. Faça um fork do projeto
  2. Crie uma nova branch (git checkout -b feature/nome-da-feature)
  3. Faça commit das suas alterações (git commit -am 'Adiciona nova feature')
  4. Faça push para a branch (git push origin feature/nome-da-feature)
  5. Abra um Pull Request

Licença

Este projeto está licenciado sob a Licença MIT - veja o arquivo LICENSE para mais detalhes.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL