Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

feature/hashing #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Sources/BeaconChain/BeaconChain.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Foundation

import CommonCrypto
// @todo figure out better name
// @todo refactor so this isn't all in one class

class BeaconChain {

static func hash(_ data: Any) -> Data {
// @todo
return Data(count: 0)
static func hash(_ data: Data) -> Data {
var hash = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
CC_SHA256(Array(data), CC_LONG(data.count), &hash)
return Data(bytes: &hash, count: hash.count)
}

static func hashTreeRoot(_ data: Any) -> Data {
Expand Down