Skip to content
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
6 changes: 3 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "hyperdrive_lib"
authors = ["Sybil Technologies AG"]
version = "1.1.0"
version = "1.1.1"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://hyperware.ai"
Expand Down
2 changes: 1 addition & 1 deletion hyperdrive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "hyperdrive"
authors = ["Sybil Technologies AG"]
version = "1.1.0"
version = "1.1.1"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://hyperware.ai"
Expand Down
6 changes: 2 additions & 4 deletions hyperdrive/packages/hns-indexer/hns-indexer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ fn handle_note(state: &mut State, note: &hypermap::contract::Note) -> anyhow::Re
let Some(node_name) = state.names.get(&node_hash) else {
return Err(HnsError::NoParentError.into());
};
print_to_terminal(3, &format!("note {node_name}: {note_label}"));

match note_label.as_str() {
"~ws-port" => {
Expand Down Expand Up @@ -554,6 +555,7 @@ fn handle_log(
Some(parent_name) => format!("{name}.{parent_name}"),
None => name,
};
print_to_terminal(3, &format!("mint {full_name}"));

state.names.insert(child_hash.clone(), full_name.clone());
state.nodes.insert(
Expand All @@ -578,10 +580,6 @@ fn handle_log(
if let Err(e) = handle_note(state, &decoded) {
if let Some(HnsError::NoParentError) = e.downcast_ref::<HnsError>() {
if let Some(block_number) = log.block_number {
// print_to_terminal(
// 1,
// &format!("adding note to pending_notes for block {block_number}"),
// );
pending_notes
.entry(block_number)
.or_default()
Expand Down
16 changes: 7 additions & 9 deletions hyperdrive/src/fakenet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ use std::str::FromStr;

use crate::{keygen, sol::*, HYPERMAP_ADDRESS, HYPER_ACCOUNT_IMPL, MULTICALL_ADDRESS};

const FAKE_DOTDEV_TBA: &str = "0xcc3A576b8cE5340f5CE23d0DDAf133C0822C3B6d";
const FAKE_DOTOS_TBA: &str = "0xbE46837617f8304Aa5E6d0aE62B74340251f48Bf";
const _FAKE_ZEROTH_TBA: &str = "0x4bb0778bb92564bf8e82d0b3271b7512443fb060";
const FAKE_DOTOS_TBA: &str = "0x9b3853358ede717fc7D4806cF75d7A4d4517A9C9";
const _FAKE_ZEROTH_TBA: &str = "0x809A598d9883f2Fb6B77382eBfC9473Fd6A857c9";

/// Attempts to connect to a local anvil fakechain,
/// registering a name with its KiMap contract.
Expand All @@ -35,16 +34,18 @@ pub async fn mint_local(

let multicall_address = Address::from_str(MULTICALL_ADDRESS)?;
let dotos = Address::from_str(FAKE_DOTOS_TBA)?;
let dotdev = Address::from_str(FAKE_DOTDEV_TBA)?;
let hypermap = Address::from_str(HYPERMAP_ADDRESS)?;

let parts: Vec<&str> = name.split('.').collect();
let label = parts[0];
let minter = match parts.get(1) {
Some(&"os") => dotos,
Some(&"dev") => dotdev,
_ => dotdev,
_ => dotos,
};
println!(
"mint_local name, tlz, tlz address: {name}, {:?}, {minter}",
parts.get(1)
);

let endpoint = format!("ws://localhost:{}", fakechain_port);
let ws = WsConnect::new(endpoint);
Expand All @@ -64,7 +65,6 @@ pub async fn mint_local(
.input(TransactionInput::new(get_call.into()));

let exists = provider.call(&get_tx).await?;
println!("exists: {:?}", exists);

let decoded = getCall::abi_decode_returns(&exists, false)?;

Expand All @@ -73,8 +73,6 @@ pub async fn mint_local(
let bytes = decoded.data;
// now set ip, port and pubkey

println!("tba, owner and bytes: {:?}, {:?}, {:?}", tba, _owner, bytes);

let localhost = Ipv4Addr::new(127, 0, 0, 1);
let ip = keygen::ip_to_bytes(localhost.into());
let pubkey = hex::decode(pubkey)?;
Expand Down
12 changes: 10 additions & 2 deletions hyperdrive/src/http/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,16 @@ <h3>Logging in...</h3>
document.getElementById("loading").style.display = "flex";

try {
// salt is either node name (if node name is longer than 8 characters)
// or node name repeated enough times to be longer than 8 characters
const hnsName = `${node}`;
const minSaltL = 8;
const nameL = hnsName.length;
const salt = nameL >= minSaltL ? hnsName : hnsName.repeat(1 + Math.floor(minSaltL / nameL));

const h = await argon2.hash({
pass: password,
salt: '${node}',
salt: salt,
hashLen: 32,
time: 2,
mem: 19456,
Expand All @@ -186,6 +193,7 @@ <h3>Logging in...</h3>
throw new Error("Login failed");

} catch (err) {
console.log(`login failed with err: ${JSON.stringify(err)}`);
document.getElementById("login-form").style.display = "flex";
document.getElementById("loading").style.display = "none";
document.getElementById("password").value = "";
Expand Down Expand Up @@ -220,4 +228,4 @@ <h3>Logging in...</h3>
</script>
</body>

</html>
</html>
2 changes: 2 additions & 0 deletions hyperdrive/src/http/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ async fn login_handler(
subdomain: info.subdomain,
};

println!("login_handler: got info {info:?}\r");

match keygen::decode_keyfile(&encoded_keyfile, &info.password_hash) {
Ok(keyfile) => {
let token = match keygen::generate_jwt(
Expand Down
12 changes: 11 additions & 1 deletion hyperdrive/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -902,11 +902,21 @@ async fn login_with_password(
})
.unwrap();

// salt is either node name (if node name is longer than 8 characters)
// or node name repeated enough times to be longer than 8 characters
let min_salt_len = 8;
let name_len = username.len();
let salt = if name_len >= min_salt_len {
username
} else {
username.repeat(1 + min_salt_len / name_len)
};

let mut output_key_material = [0u8; 32];
Argon2::default()
.hash_password_into(
password.as_bytes(),
username.as_bytes(),
salt.as_bytes(),
&mut output_key_material,
)
.expect("password hashing failed");
Expand Down
16 changes: 15 additions & 1 deletion hyperdrive/src/register-ui/src/pages/ImportKeyfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,21 @@ function ImportKeyfile({

try {
if (keyErrs.length === 0 && localKey !== null) {
argon2.hash({ pass: pw, salt: hnsName, hashLen: 32, time: 2, mem: 19456, type: argon2.ArgonType.Argon2id }).then(async h => {
// salt is either node name (if node name is longer than 8 characters)
// or node name repeated enough times to be longer than 8 characters
const minSaltL = 8;
const nodeL = hnsName.length;
const salt = nodeL >= minSaltL ? hnsName : hnsName.repeat(1 + Math.floor(minSaltL / nodeL));
console.log(salt);

argon2.hash({
pass: pw,
salt: salt,
hashLen: 32,
time: 2,
mem: 19456,
type: argon2.ArgonType.Argon2id
}).then(async h => {
const hashed_password_hex = `0x${h.hashHex}`;

const result = await fetch("/import-keyfile", {
Expand Down
12 changes: 10 additions & 2 deletions hyperdrive/src/register-ui/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,17 @@ function Login({

try {
// Try argon2 hash first

// salt is either node name (if node name is longer than 8 characters)
// or node name repeated enough times to be longer than 8 characters
const minSaltL = 8;
const nodeL = hnsName.length;
const salt = nodeL >= minSaltL ? hnsName : hnsName.repeat(1 + Math.floor(minSaltL / nodeL));
console.log(salt);

const h = await argon2.hash({
pass: pw,
salt: hnsName,
salt: salt,
hashLen: 32,
time: 2,
mem: 19456,
Expand Down Expand Up @@ -136,4 +144,4 @@ function Login({
);
}

export default Login;
export default Login;
19 changes: 17 additions & 2 deletions hyperdrive/src/register-ui/src/pages/SetPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,22 @@ function SetPassword({

setTimeout(async () => {
setLoading(true);
argon2.hash({ pass: pw, salt: hnsName, hashLen: 32, time: 2, mem: 19456, type: argon2.ArgonType.Argon2id }).then(async h => {

// salt is either node name (if node name is longer than 8 characters)
// or node name repeated enough times to be longer than 8 characters
const minSaltL = 8;
const nodeL = hnsName.length;
const salt = nodeL >= minSaltL ? hnsName : hnsName.repeat(1 + Math.floor(minSaltL / nodeL));
console.log(salt);

argon2.hash({
pass: pw,
salt: salt,
hashLen: 32,
time: 2,
mem: 19456,
type: argon2.ArgonType.Argon2id
}).then(async h => {
const hashed_password_hex = `0x${h.hashHex}` as `0x${string}`;
let owner = address;
let timestamp = Date.now();
Expand Down Expand Up @@ -160,4 +175,4 @@ function SetPassword({
);
}

export default SetPassword;
export default SetPassword;
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lib"
authors = ["Sybil Technologies AG"]
version = "1.1.0"
version = "1.1.1"
edition = "2021"
description = "A general-purpose sovereign cloud computing platform"
homepage = "https://hyperware.ai"
Expand Down