Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single chain validation #17

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
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
48 changes: 0 additions & 48 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ members = ["zomes/*"]
serde = "1"
rmp-serde = "1"
serde_bytes = "0.11"
hc_deepkey_types = { path = "dnas/deepkey/types" }
# hc_deepkey_types = "0.1"
hdi = { version = "0.4.0-beta-dev.20" }
hdk = { version = "0.3.0-beta-dev.24" }
holo_hash = { version = "0.3.0-beta-dev.16", features = ["hashing"] }
Expand Down
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ DEEPKEY_CSR_WASM = zomes/deepkey_csr.wasm

TARGET = release
TARGET_DIR = target/wasm32-unknown-unknown/release
COMMON_SOURCE_FILES = Makefile Cargo.toml
COMMON_SOURCE_FILES = Makefile Cargo.toml \
dnas/deepkey/types/Cargo.toml dnas/deepkey/types/src/*.rs
INT_SOURCE_FILES = $(COMMON_SOURCE_FILES) \
$(INT_DIR)/Cargo.toml $(INT_DIR)/src/*.rs $(INT_DIR)/src/validation/*.rs
CSR_SOURCE_FILES = $(INT_SOURCE_FILES) \
Expand Down Expand Up @@ -101,3 +102,17 @@ docs-watch:
echo -e "\x1b[37m$$event $$dir$$file\x1b[0m";\
make docs; \
done


#
# Publishing Types Packages
#
.cargo/credentials:
cp ~/$@ $@
preview-%-types-crate: .cargo/credentials
cd dnas/$*; make preview-types-crate
publish-%-types-crate: .cargo/credentials
cd dnas/$*; make publish-types-crate

preview-deepkey-types-crate:
publish-deepkey-types-crate:
16 changes: 16 additions & 0 deletions dnas/deepkey/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

NAME = deepkey

fix-rust-compile-issue: # Force rebuild to fix rust issue (typically after dry-run)
touch types/src/lib.rs



#
# Types package
#
preview-types-crate:
cargo publish -p hc_$(NAME)_types --dry-run --allow-dirty
make fix-rust-compile-issue
publish-types-crate:
cargo publish -p hc_$(NAME)_types
4 changes: 2 additions & 2 deletions dnas/deepkey/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ name = "deepkey_types"
crate-type = ["cdylib", "rlib"]

[dependencies]
hdi = { workspace = true }
hdi = { version = "0.4.0-beta-dev.20" }
holo_hash = { version = "0.3.0-beta-dev.16", features = ["hashing", "encoding"] }
serde = "1"
whi_hdi_extensions = { workspace = true }
11 changes: 11 additions & 0 deletions dnas/deepkey/types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[![](https://img.shields.io/crates/v/hc_deepkey_types?style=flat-square)](https://crates.io/crates/hc_deepkey_types)

See source code [github.com/holochain/deepkey](https://github.com/holochain/deepkey)

# Deepkey Types
Definitions used by the Deepkey DNA Zomes.


## Crate Documentation

See [docs.rs/hc_deepkey_types](https://docs.rs/hc_deepkey_types/)
23 changes: 0 additions & 23 deletions dnas/deepkey/types/src/device_invite.rs

This file was deleted.

21 changes: 0 additions & 21 deletions dnas/deepkey/types/src/device_invite_acceptance.rs

This file was deleted.

7 changes: 2 additions & 5 deletions dnas/deepkey/types/src/key_anchor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use hdi::prelude::*;
use hdi_extensions::{
guest_error,
};


pub type KeyBytes = [u8; 32];
Expand Down Expand Up @@ -29,9 +26,9 @@ impl TryFrom<AgentPubKey> for KeyAnchor {
Ok(
Self {
bytes: input.get_raw_32().try_into()
.map_err( |e| guest_error!(format!(
.map_err( |e| wasm_error!(WasmErrorInner::Guest(format!(
"Failed AgentPubKey to [u8;32] conversion: {:?}", e
)) )?,
))) )?,
}
)
}
Expand Down
7 changes: 2 additions & 5 deletions dnas/deepkey/types/src/key_registration.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
use hdi::prelude::*;
use hdi_extensions::{
guest_error,
};

use crate::{
KeyAnchor,
Expand Down Expand Up @@ -93,9 +90,9 @@ impl KeyRegistration {
KeyRegistration::Create(key_gen) => key_gen.new_key.to_owned(),
KeyRegistration::CreateOnly(key_gen) => key_gen.new_key.to_owned(),
KeyRegistration::Update(_, key_gen) => key_gen.new_key.to_owned(),
KeyRegistration::Delete(_) => Err(guest_error!(
KeyRegistration::Delete(_) => Err(wasm_error!(WasmErrorInner::Guest(
"Cannot derive KeyAnchor from a KeyRegistration::Delete".to_string()
))?,
)))?,
}.try_into()
}

Expand Down
7 changes: 0 additions & 7 deletions dnas/deepkey/types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
pub mod authority_spec;
pub mod authorized_spec_change;
pub mod change_rule;
pub mod device_invite;
pub mod device_invite_acceptance;
pub mod app_binding;
pub mod key_anchor;
pub mod key_meta;
pub mod key_registration;
pub mod keyset_root;

pub use hdi_extensions;
pub use hdi_extensions::hdi;

pub use authorized_spec_change::*;
pub use authority_spec::*;
pub use change_rule::*;
pub use device_invite_acceptance::*;
pub use device_invite::*;
pub use app_binding::*;
pub use keyset_root::*;
pub use key_anchor::*;
Expand Down
63 changes: 7 additions & 56 deletions dnas/deepkey/zomelets/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
KeyAnchor,
KeyState,
AppBinding,
DeviceInvite,
DeviceInviteAcceptance,

KeyRegistrationEntry,
KeyInfo,
Expand Down Expand Up @@ -69,22 +67,6 @@ const functions = {

return KeysetRoot( result );
},
async get_ksr_members ( input ) {
const result = await this.call( input );

return result.map( agent => new AgentPubKey(agent) );
},
// async get_ksr_members_with_keys ( input ) {
// const result = await this.call( input );

// return result.map( ([ agent, keys ]) => ({
// "member": new AgentPubKey(agent),
// "keys": keys.map( ([ hash, key_anchor ]) => ({
// "hash": new EntryHash( hash ),
// "anchor": KeyAnchor( key_anchor ),
// }) ),
// }) );
// },
async get_device_keys ( input ) {
const result = await this.call( input );

Expand Down Expand Up @@ -138,17 +120,13 @@ const functions = {
KeyRegistrationEntry( result[1] ),
];
},

// Device Inviting
async invite_agent ( input ) {
const result = await this.call( input );

return DeviceInviteAcceptance( result );
},
async accept_invite ( input ) {
async delete_key_registration ( input ) {
const result = await this.call( input );

return new ActionHash( result );
return [
new ActionHash( result[0] ),
KeyRegistrationEntry( input[1] ),
];
},

// Change Rules
Expand Down Expand Up @@ -176,35 +154,10 @@ const functions = {
//
// Virtual functions
//
async get_ksr_members_with_keys ( input ) {
const devices = [];
const members = await this.functions.get_ksr_members( input );

for ( let agent of members ) {
devices.push({
"member": agent,
"keys": await this.functions.get_device_keys( agent ),
});
}

return devices;
},
async get_ksr_keys ( input ) {
const keys = [];
const members = await this.functions.get_ksr_members( input );

for ( let agent of members ) {
const device_keys = await this.functions.get_device_keys( agent );

keys.push(
...device_keys.map( key_anchor => ({
"member": agent,
"anchor": key_anchor,
}) )
);
}
const ksr = await this.functions.get_keyset_root ( input );

return keys;
return await this.functions.get_device_keys( ksr.first_deepkey_agent );
},
};

Expand All @@ -214,8 +167,6 @@ const APP_ENTRY_STRUCTS_MAP = {
KeyMeta,
KeyAnchor,
AppBinding,
DeviceInvite,
DeviceInviteAcceptance,
"KeyRegistration": KeyRegistrationEntry,
};

Expand Down
27 changes: 0 additions & 27 deletions dnas/deepkey/zomelets/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,6 @@ export function AppBinding ( data ) {
}


export const DeviceInviteStruct = {
"keyset_root": ActionHash,
"parent": ActionHash,
"invitee": AgentPubKey,
};

export function DeviceInvite ( data ) {
return intoStruct( data, DeviceInviteStruct );
}


export const DeviceInviteAcceptanceStruct = {
"keyset_root_authority": ActionHash,
"invite": ActionHash,
};

export function DeviceInviteAcceptance ( data ) {
return intoStruct( data, DeviceInviteAcceptanceStruct );
}


export const KeyGenerationStruct = {
"new_key": AgentPubKey,
"new_key_signing_of_author": Signature,
Expand Down Expand Up @@ -298,12 +277,6 @@ export default {
AppBindingStruct,
AppBinding,

DeviceInviteStruct,
DeviceInvite,

DeviceInviteAcceptanceStruct,
DeviceInviteAcceptance,

KeyGenerationStruct,
KeyRevocationStruct,
KeyRegistrationEntry,
Expand Down
Loading