Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCredentialHash ¶
func GenerateCredentialHash(cred *Credential) []byte
GenerateCredentialHash creates a hash of the credential data for integrity
func RevokeCredential ¶
func RevokeCredential(s *Student, cred Credential) error
RevokeCredential revokes a credential of the student
func ValidateCredentialData ¶
func ValidateCredentialData(cred *Credential) error
ValidateCredentialData ensures the credential fields are valid.
Types ¶
type Admin ¶
func (*Admin) AddCredentialAdmin ¶
func (a *Admin) AddCredentialAdmin(s *Student, credentialType CredentialType, issuer string, dateIssued time.Time) bool
AddCredentialAdmin adds a new academic credential to the student's list of academic credentials
type Block ¶
Block represents a block in the blockchain.
func CreateBlock ¶
CreateBlock creates a new block with the given data and previous hash.
func (*Block) DeriveHash ¶
func (b *Block) DeriveHash()
DeriveHash generates a hash for the block using its index, timestamp, data, and previous hash.
func (*Block) SetPrevHash ¶
SetPrevHash sets the previous hash for the block.
type BlockChain ¶
type BlockChain struct {
Blocks []Block
}
BlockChain structure contains a slice of blocks.
func NewBlockChain ¶
func NewBlockChain() *BlockChain
NewBlockChain creates a blockchain with the genesis block.
func (*BlockChain) AddBlock ¶
func (chain *BlockChain) AddBlock(blockData []byte)
AddBlock adds a new block to the blockchain.
func (*BlockChain) FindCredentialByID ¶
func (chain *BlockChain) FindCredentialByID(id string) (*Credential, error)
FindCredentialByID searches the blockchain for a credential with the given ID.
type Credential ¶
type Credential struct { ID string `json:"id"` Type CredentialType `json:"type"` Issuer string `json:"issuer"` DateIssued time.Time `json:"date_issued"` Hash []byte `json:"hash"` Status string `json:"status"` }
Credential represents an individual credential.
func (*Credential) Serialize ¶
func (cred *Credential) Serialize() []byte
Serialize converts the Credential to a custom byte array format
type CredentialChain ¶
type CredentialChain struct {
BlockChain
}
CredentialChain is an alias for BlockChain, which stores credentials.
func (*CredentialChain) AddCredential ¶
func (chain *CredentialChain) AddCredential(cred *Credential) error
AddCredential adds a new credential to the blockchain.
func (*CredentialChain) VerifyCredential ¶
func (chain *CredentialChain) VerifyCredential(id string) (bool, error)
VerifyCredential checks if a credential exists in the blockchain.
type CredentialType ¶
type CredentialType int
CredentialType enumeration
const ( Academic CredentialType = iota NonAcademic Certificate Diploma )
func (CredentialType) String ¶
func (ct CredentialType) String() string
type Student ¶
type Student struct { ID int `json:"user_id"` LastName string `json:"last_name"` FirstName string `json:"first_name"` BirthDate time.Time `json:"birth_date"` StudentID int `json:"student_id"` Credentials []*Credential `json:"credentials,omitempty"` }
func (*Student) AddCredential ¶
func (s *Student) AddCredential(credentialType CredentialType, issuer string, dataIssued time.Time) bool
AddCredential adds a new credential to the student's list of non-academic credentials
type StudentChain ¶
func (*StudentChain) FindStudentByID ¶
func (chain *StudentChain) FindStudentByID(id int) (*Student, error)
FindStudentByID should find and return a student by ID (this needs to be implemented)
func (*StudentChain) UpdateStudentCredentials ¶
func (chain *StudentChain) UpdateStudentCredentials(id int, newCredential Credential) bool
UpdateStudentCredentials updates the credentials of the student