18 Commits
Author SHA1 Message Date
zeekay d3443646cb chore: sync working tree
Commits 1 outstanding change(s) that were sitting uncommitted.
No build artifacts and no secrets in the changeset (both checked).
2026-07-26 10:13:35 -07:00
zeekay 8b8e4a9496 fix(deps): correct moved-tag hashes for luxfi modules in go.sum
Several luxfi versions carry TWO different contents across this workspace,
because published tags were moved instead of a new patch being cut:
age@v1.5.0, pq@v1.0.3, threshold@v1.9.4, zap@v0.6.0, zap@v0.8.1.

Adjudicated before editing, since "checksum mismatch / SECURITY ERROR" is also
what a real supply-chain attack looks like. It is not one here: sum.golang.org
holds the OLD hash while proxy.golang.org and a direct fetch BOTH serve the same
NEW bytes. Two independent transports agreeing means nothing is rewriting
content in flight — the tag moved at source. The sumdb entry is a fossil:
GOPRIVATE covers github.com/luxfi/* with GOSUMDB=off, so our own modules never
consult the checksum DB and a moved tag splits consumers silently.

The old bytes are served by nothing now, so a stale pin can never build.
Corrected to the only content that exists, in BOTH line forms (h1: and
/go.mod h1:) — Go reports these one at a time, so a partial fix just relocates
the error.

Deliberately no `go mod tidy`: this changes no selected version, only the
recorded hash of versions already chosen.

Verified: `go list -m all` resolves with no checksum error.

The durable fix is upstream: never move a published tag, cut x.y.z+1 instead.
2026-07-26 02:42:49 -07:00
z d065027471 docs(brand): add hero banner 2026-06-28 20:57:15 -07:00
z 474e78ee46 chore(brand): dynamic hero banner 2026-06-28 20:57:14 -07:00
Hanzo AI a831cf8a47 go: 1.26.3 → 1.26.4 (security: crypto/x509, mime, net/textproto) 2026-06-06 22:05:41 -07:00
Hanzo AI e663296ee4 chore(deps): go get -u ./...
Updated dependencies to latest minor versions via go get -u + go mod tidy.
2026-06-02 11:12:53 -07:00
Hanzo DevandGitHub 63c018e6f3 docs: add LICENSING.md pointer to canonical IP/licensing strategy (#1) 2026-05-15 17:33:32 -07:00
Hanzo AI 2525fb15bd go.mod: bump go directive to 1.26.3 (security advisory) 2026-05-12 21:29:42 -07:00
Hanzo AI 3ead335188 deps: update go.mod/go.sum 2026-04-19 17:04:32 -07:00
Hanzo Dev f7d992a286 chore: bump Go 1.26.0 → 1.26.1
Fixes 5 stdlib CVEs (html/template, os, net/url, crypto/x509 x2).
2026-03-12 01:08:42 -07:00
Hanzo Dev 983b8c12b3 chore: update Go module dependencies 2026-03-03 13:37:53 -08:00
Zach Kelling a0d63e3f0f chore: add BSD-3-Clause LICENSE 2026-02-14 05:26:20 -08:00
Zach Kelling 5aa348611a chore: sync dependencies and format code 2026-02-04 15:48:33 -08:00
Zach Kelling e62d142134 chore: update go.mod 2025-12-31 22:21:33 -08:00
Zach Kelling cdf8712bfa remove FactomProject dependencies
Replace FactomProject/basen and FactomProject/btcutilecc with:
- Custom base58 encoding/decoding implementation
- github.com/decred/dcrd/dcrec/secp256k1/v4 for curve operations

Eliminates ancient, unmaintained dependencies from binary.
2025-12-21 18:39:55 -08:00
Zach Kelling 08766a3fda chore: update Go version to 1.25.5 2025-12-20 22:26:39 -08:00
Zach Kelling bcc556ef7a Update go.mod dependencies 2025-09-24 02:39:01 +00:00
Hanzo Dev b9b7e79ac4 Fix outdated dep 2025-08-03 14:50:28 -05:00
23 changed files with 604 additions and 44 deletions
+9
View File
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="640" viewBox="0 0 1280 640" role="img" aria-label="go-bip32">
<rect width="1280" height="640" fill="#0A0A0A"/>
<svg x="96" y="215" width="210" height="210" viewBox="17 26 66 66"><path d="M50 88 L17.09 31 L82.91 31 Z" fill="#fff"/></svg>
<text x="378" y="276" font-family="Inter,system-ui,-apple-system,sans-serif" font-size="78" font-weight="800" letter-spacing="-2" fill="#ffffff">go-bip32</text>
<text x="378" y="322" font-family="Inter,system-ui,sans-serif" font-size="30" fill="#ffffff" opacity=".66">BIP-32 HD key derivation library for Go: generate and manage…</text>
<rect x="378" y="338" width="806" height="3" rx="1.5" fill="#ffffff" opacity=".9"/>
<text x="378" y="390" font-family="Inter,system-ui,sans-serif" font-size="24" font-weight="600" fill="#ffffff" opacity=".5">github.com/luxfi</text>
<text x="1184" y="390" text-anchor="end" font-family="Inter,system-ui,sans-serif" font-size="24" font-weight="600" fill="#ffffff" opacity=".5">lux.network</text>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

+8 -1
View File
@@ -137,4 +137,11 @@ fabric.properties
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml
# End of https://www.toptal.com/developers/gitignore/api/goland,go
# End of https://www.toptal.com/developers/gitignore/api/goland,go
AGENTS.md
CLAUDE.md
GEMINI.md
GROK.md
QWEN.md
+29
View File
@@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2024, Lux Partners Limited
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+8
View File
@@ -0,0 +1,8 @@
# Licensing
This repository is licensed under the **BSD-3-Clause License** (see [LICENSE](LICENSE)). It belongs to the **public** tier of the Lux three-tier IP strategy: anyone may use, fork, or redistribute it, including for commercial purposes, subject to the BSD-3-Clause License terms.
For the canonical Lux IP and licensing strategy, see:
<https://github.com/luxfi/.github/blob/main/profile/README.md>
For commercial inquiries that go beyond the public tier (e.g. private moat acceleration kernels, Eco-tier patent-protected primitives outside Authorized Networks), contact `licensing@lux.network`.
+42
View File
@@ -0,0 +1,42 @@
# AI Assistant Knowledge Base
**Last Updated**: $(date +%Y-%m-%d)
**Project**: $(basename "$REPO_PATH")
**Organization**: $(basename "$(dirname "$REPO_PATH")")
## Project Overview
This repository is part of the $(basename "$(dirname "$REPO_PATH")") organization.
## Essential Commands
### Development
```bash
# Add common commands here
```
## Architecture
## Key Technologies
## Development Workflow
## Context for All AI Assistants
This file (`LLM.md`) is symlinked as:
- `.AGENTS.md`
- `CLAUDE.md`
- `QWEN.md`
- `GEMINI.md`
All files reference the same knowledge base. Updates here propagate to all AI systems.
## Rules for AI Assistants
1. **ALWAYS** update LLM.md with significant discoveries
2. **NEVER** commit symlinked files (.AGENTS.md, CLAUDE.md, etc.) - they're in .gitignore
3. **NEVER** create random summary files - update THIS file
---
**Note**: This file serves as the single source of truth for all AI assistants working on this project.
+2
View File
@@ -1,3 +1,5 @@
<p align="center"><img src=".github/hero.svg" alt="go-bip32" width="880"></p>
# GO-BIP32
This repository contains a local copy of the original ``github.com/tyler-smith/go-bip32`` library.
+34
View File
@@ -0,0 +1,34 @@
# Dependencies
node_modules/
.pnpm-store/
# Next.js
.next/
out/
.turbo/
# Build
dist/
build/
# Environment
.env
.env.local
.env.*.local
# IDE
.vscode/
.idea/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
# Fumadocs
.source/
# TypeScript
*.tsbuildinfo
next-env.d.ts
+42
View File
@@ -0,0 +1,42 @@
import { source } from "@/lib/source"
import type { Metadata } from "next"
import { DocsPage, DocsBody, DocsTitle, DocsDescription } from "fumadocs-ui/page"
import { notFound } from "next/navigation"
import defaultMdxComponents from "fumadocs-ui/mdx"
export default async function Page(props: {
params: Promise<{ slug?: string[] }>
}) {
const params = await props.params
const page = source.getPage(params.slug)
if (!page) notFound()
const MDX = page.data.body
return (
<DocsPage toc={page.data.toc} full={page.data.full}>
<DocsTitle>{page.data.title}</DocsTitle>
<DocsDescription>{page.data.description}</DocsDescription>
<DocsBody>
<MDX components={{ ...defaultMdxComponents }} />
</DocsBody>
</DocsPage>
)
}
export async function generateStaticParams() {
return source.generateParams()
}
export async function generateMetadata(props: {
params: Promise<{ slug?: string[] }>
}): Promise<Metadata> {
const params = await props.params
const page = source.getPage(params.slug)
if (!page) notFound()
return {
title: page.data.title,
description: page.data.description,
}
}
+11
View File
@@ -0,0 +1,11 @@
import { source } from "@/lib/source"
import type { ReactNode } from "react"
import { DocsLayout } from "fumadocs-ui/layouts/docs"
export default async function Layout({ children }: { children: ReactNode }) {
return (
<DocsLayout tree={source.pageTree} sidebar={{ defaultOpenLevel: 0 }}>
{children}
</DocsLayout>
)
}
+79
View File
@@ -0,0 +1,79 @@
@import "tailwindcss";
@import "fumadocs-ui/style.css";
@custom-variant dark (&:is(.dark *));
@theme inline {
--breakpoint-3xl: 1600px;
--breakpoint-4xl: 2000px;
--font-sans: var(--font-geist-sans), system-ui, sans-serif;
--font-mono: var(--font-geist-mono), monospace;
--radius-sm: calc(var(--radius) - 4px);
--radius-md: calc(var(--radius) - 2px);
--radius-lg: var(--radius);
--radius-xl: calc(var(--radius) + 4px);
--color-background: var(--background);
--color-foreground: var(--foreground);
--color-card: var(--card);
--color-card-foreground: var(--card-foreground);
--color-popover: var(--popover);
--color-popover-foreground: var(--popover-foreground);
--color-primary: var(--primary);
--color-primary-foreground: var(--primary-foreground);
--color-secondary: var(--secondary);
--color-secondary-foreground: var(--secondary-foreground);
--color-muted: var(--muted);
--color-muted-foreground: var(--muted-foreground);
--color-accent: var(--accent);
--color-accent-foreground: var(--accent-foreground);
--color-destructive: var(--destructive);
--color-destructive-foreground: var(--destructive-foreground);
--color-border: var(--border);
--color-input: var(--input);
--color-ring: var(--ring);
}
:root {
--background: 0 0% 100%;
--foreground: 0 0% 3.9%;
--card: 0 0% 100%;
--card-foreground: 0 0% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 0 0% 3.9%;
--primary: 0 0% 9%;
--primary-foreground: 0 0% 98%;
--secondary: 0 0% 96.1%;
--secondary-foreground: 0 0% 9%;
--muted: 0 0% 96.1%;
--muted-foreground: 0 0% 45.1%;
--accent: 0 0% 96.1%;
--accent-foreground: 0 0% 9%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 89.8%;
--input: 0 0% 89.8%;
--ring: 0 0% 3.9%;
--radius: 0.5rem;
}
.dark {
--background: 0 0% 3.9%;
--foreground: 0 0% 98%;
--card: 0 0% 3.9%;
--card-foreground: 0 0% 98%;
--popover: 0 0% 3.9%;
--popover-foreground: 0 0% 98%;
--primary: 0 0% 98%;
--primary-foreground: 0 0% 9%;
--secondary: 0 0% 14.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 14.9%;
--muted-foreground: 0 0% 63.9%;
--accent: 0 0% 14.9%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 0% 98%;
--border: 0 0% 14.9%;
--input: 0 0% 14.9%;
--ring: 0 0% 83.1%;
}
+50
View File
@@ -0,0 +1,50 @@
import "./global.css"
import { RootProvider } from "fumadocs-ui/provider/next"
import { Inter } from "next/font/google"
import type { ReactNode } from "react"
const inter = Inter({
subsets: ["latin"],
variable: "--font-geist-sans",
display: "swap",
})
const interMono = Inter({
subsets: ["latin"],
variable: "--font-geist-mono",
display: "swap",
})
export const metadata = {
title: {
default: "BIP32 HD Wallet Implementation Documentation",
template: "%s | BIP32 HD Wallet Implementation",
},
description: "Hierarchical deterministic wallet key derivation",
}
export default function Layout({ children }: { children: ReactNode }) {
return (
<html
lang="en"
className={`${inter.variable} ${interMono.variable}`}
suppressHydrationWarning
>
<body className="min-h-svh bg-background font-sans antialiased">
<RootProvider
search={{
enabled: true,
}}
theme={{
enabled: true,
defaultTheme: "dark",
}}
>
<div className="relative flex min-h-svh flex-col bg-background">
{children}
</div>
</RootProvider>
</body>
</html>
)
}
+26
View File
@@ -0,0 +1,26 @@
import Link from "next/link"
export default function HomePage() {
return (
<main className="flex flex-1 flex-col items-center justify-center px-4">
<div className="container flex flex-col items-center gap-12 py-24 sm:gap-16 sm:py-32">
<div className="flex flex-col items-center gap-4 text-center">
<h1 className="text-4xl font-bold tracking-tight sm:text-6xl">
Documentation
</h1>
<p className="max-w-2xl text-lg text-muted-foreground">
Get started with our comprehensive documentation
</p>
</div>
<div className="flex gap-4">
<Link
href="/docs"
className="inline-flex h-10 items-center justify-center rounded-md bg-primary px-8 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90"
>
Get Started
</Link>
</div>
</div>
</main>
)
}
+18
View File
@@ -0,0 +1,18 @@
import { docs } from "@/.source"
import { loader } from "fumadocs-core/source"
// Create a single source instance that is reused
// This prevents circular references and stack overflow issues
let _source: ReturnType<typeof loader> | null = null
export function getSource() {
if (!_source) {
_source = loader({
baseUrl: "/docs",
source: docs.toFumadocsSource(),
})
}
return _source
}
export const source = getSource()
+9
View File
@@ -0,0 +1,9 @@
import type { MDXComponents } from "mdx/types"
import defaultMdxComponents from "fumadocs-ui/mdx"
export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
...defaultMdxComponents,
...components,
}
}
+20
View File
@@ -0,0 +1,20 @@
import { createMDX } from "fumadocs-mdx/next"
/** @type {import('next').NextConfig} */
const config = {
output: 'export',
reactStrictMode: true,
typescript: {
ignoreBuildErrors: true,
},
experimental: {
webpackBuildWorker: true,
},
images: {
unoptimized: true,
},
}
const withMDX = createMDX()
export default withMDX(config)
+36
View File
@@ -0,0 +1,36 @@
{
"name": "@luxfi/go-bip32-docs",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "next dev --port 3001",
"build": "fumadocs-mdx && TURBOPACK=0 next build",
"export": "TURBOPACK=0 next build",
"start": "next start",
"lint": "next lint",
"postinstall": "fumadocs-mdx"
},
"dependencies": {
"fumadocs-core": "^15.8.5",
"fumadocs-mdx": "^12.0.3",
"fumadocs-ui": "^15.8.5",
"lucide-react": "^0.468.0",
"next": "16.0.1",
"react": "19.2.0",
"react-dom": "19.2.0",
"tailwindcss": "^4.1.16",
"zod": "^3.24.1"
},
"devDependencies": {
"@tailwindcss/postcss": "^4.1.16",
"@types/node": "^22.10.2",
"@types/react": "^19.0.1",
"@types/react-dom": "^19.0.2",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.49",
"rehype-pretty-code": "^0.14.1",
"shiki": "^1.27.2",
"typescript": "^5.7.2"
},
"packageManager": "pnpm@10.12.4"
}
+6
View File
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
'@tailwindcss/postcss': {},
autoprefixer: {},
},
}
View File
+27
View File
@@ -0,0 +1,27 @@
import {
defineConfig,
defineDocs,
} from "fumadocs-mdx/config"
import rehypePrettyCode from "rehype-pretty-code"
export default defineConfig({
mdxOptions: {
rehypePlugins: [
[
rehypePrettyCode,
{
theme: {
dark: "github-dark-dimmed",
light: "github-light",
},
keepBackground: false,
defaultLang: "go",
},
],
],
},
})
export const docs = defineDocs({
dir: "content/docs",
})
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}
+9 -9
View File
@@ -1,18 +1,18 @@
module github.com/luxfi/go-bip32
go 1.24
go 1.26.4
require (
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec
github.com/stretchr/testify v1.10.0
golang.org/x/crypto v0.40.0
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1
github.com/stretchr/testify v1.11.1
golang.org/x/crypto v0.53.0
)
require (
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 // indirect
)
+24 -17
View File
@@ -1,20 +1,27 @@
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e h1:ahyvB3q25YnZWly5Gq1ekg6jcmWaGj/vG/MhF4aisoc=
github.com/FactomProject/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:kGUqhHd//musdITWjFvNTHn90WG9bMLBEPQZ17Cmlpw=
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec h1:1Qb69mGp/UtRPn422BH4/Y4Q3SLUrD9KHuDkm8iodFc=
github.com/FactomProject/btcutilecc v0.0.0-20130527213604-d3a63a5752ec/go.mod h1:CD8UlnlLDiqb36L110uqiP2iSflVjx9g/3U9hCI4q2U=
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e h1:0XBUw73chJ1VYSsfvcPvVT7auykAJce9FpRr10L6Qhw=
github.com/cmars/basen v0.0.0-20150613233007-fe3947df716e/go.mod h1:P13beTBKr5Q18lJe1rIoLUqjM+CB1zYrRg44ZqGuQSA=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1 h1:5RVFMOWjMyRy8cARdy79nAmgYw3hK/4HUq48LQ6Wwqo=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.1/go.mod h1:ZXNYxsqcloTdSy/rNShjYzMhyjf0LaoftYK0p+A3h40=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/crypto v0.53.0 h1:QZ4Muo8THX6CizN2vPPd5fBGHyogrdK9fG4wLPFUsto=
golang.org/x/crypto v0.53.0/go.mod h1:DNLU434OwVakk9PzuwV8w62mAJpRJL3vsgcfp4Qnsio=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087 h1:Izowp2XBH6Ya6rv+hqbceQyw/gSGoXfH/UPoTGduL54=
launchpad.net/gocheck v0.0.0-20140225173054-000000000087/go.mod h1:hj7XX3B/0A+80Vse0e+BUHsHMTEhd0O4cpUHr/e/BUM=
+89 -17
View File
@@ -8,17 +8,16 @@ import (
"io"
"math/big"
"github.com/FactomProject/basen"
"github.com/FactomProject/btcutilecc"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"golang.org/x/crypto/ripemd160"
)
var (
curve = btcutil.Secp256k1()
curve = secp256k1.S256()
curveParams = curve.Params()
// BitcoinBase58Encoding is the encoding used for bitcoin addresses
BitcoinBase58Encoding = basen.NewEncoding("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")
// Base58 alphabet used for Bitcoin addresses
base58Alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
)
//
@@ -70,6 +69,87 @@ func hash160(data []byte) ([]byte, error) {
return hash2, nil
}
//
// Base58 Encoding (Bitcoin style)
//
func base58Encode(data []byte) string {
// Count leading zeros
var zeros int
for _, b := range data {
if b == 0 {
zeros++
} else {
break
}
}
// Convert to big integer
num := new(big.Int).SetBytes(data)
base := big.NewInt(58)
zero := big.NewInt(0)
mod := new(big.Int)
var result []byte
for num.Cmp(zero) > 0 {
num.DivMod(num, base, mod)
result = append(result, base58Alphabet[mod.Int64()])
}
// Add leading '1's for each leading zero byte
for i := 0; i < zeros; i++ {
result = append(result, '1')
}
// Reverse the result
for i, j := 0, len(result)-1; i < j; i, j = i+1, j-1 {
result[i], result[j] = result[j], result[i]
}
return string(result)
}
func base58Decode(data string) ([]byte, error) {
// Count leading '1's (zeros in output)
var zeros int
for _, c := range data {
if c == '1' {
zeros++
} else {
break
}
}
// Build alphabet index map
alphabetMap := make(map[rune]int64)
for i, c := range base58Alphabet {
alphabetMap[c] = int64(i)
}
// Convert from base58
num := big.NewInt(0)
base := big.NewInt(58)
for _, c := range data {
idx, ok := alphabetMap[c]
if !ok {
return nil, fmt.Errorf("invalid base58 character: %c", c)
}
num.Mul(num, base)
num.Add(num, big.NewInt(idx))
}
// Convert to bytes
result := num.Bytes()
// Add leading zeros
if zeros > 0 {
prefix := make([]byte, zeros)
result = append(prefix, result...)
}
return result, nil
}
//
// Encoding
//
@@ -91,23 +171,17 @@ func addChecksumToBytes(data []byte) ([]byte, error) {
return append(data, checksum...), nil
}
func base58Encode(data []byte) string {
return BitcoinBase58Encoding.EncodeToString(data)
}
func base58Decode(data string) ([]byte, error) {
return BitcoinBase58Encoding.DecodeString(data)
}
// Keys
func publicKeyForPrivateKey(key []byte) []byte {
return compressPublicKey(curve.ScalarBaseMult(key))
x, y := curve.ScalarBaseMult(key)
return compressPublicKey(x, y)
}
func addPublicKeys(key1 []byte, key2 []byte) []byte {
x1, y1 := expandPublicKey(key1)
x2, y2 := expandPublicKey(key2)
return compressPublicKey(curve.Add(x1, y1, x2, y2))
x, y := curve.Add(x1, y1, x2, y2)
return compressPublicKey(x, y)
}
func addPrivateKeys(key1 []byte, key2 []byte) []byte {
@@ -189,9 +263,7 @@ func validateChildPublicKey(key []byte) error {
return nil
}
//
// Numerical
//
func uint32Bytes(i uint32) []byte {
bytes := make([]byte, 4)
binary.BigEndian.PutUint32(bytes, i)