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

starknet-tee for generating keypair (pubKey, privateKey) #2034

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

PedroRosalba
Copy link

@PedroRosalba PedroRosalba commented Jan 8, 2025

Relates to

Risks

Background

What does this PR do?

This PR creates starknet Keypair generation in Trusted Execution Environment.

What kind of change is this?

Adding a new feature to the TEE plugin on eliza

Documentation changes needed?

Yes, add the dependency "Starknet"

Testing

Where should a reviewer start?

Detailed testing steps

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @PedroRosalba! Welcome to the ai16z community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now a ai16z contributor!

@PedroRosalba
Copy link
Author

hey, how do I fix this workflow error? I couldn't understand it well

@HashWarlock
Copy link
Collaborator

hey, how do I fix this workflow error? I couldn't understand it well

You need to branch from the develop branch.

Some notes on the PR. With the Starknet Plugin already available, all you need to do to support TEE key derivation is import the TEE Plugin to Starknet plugin then create a function that will allow you to retrieve the wallet. Solana and the EVM Plugin do it this way.

EVM Plugin: 92f2564
Solana Plugin: https://github.com/elizaOS/eliza/blob/main/packages/plugin-solana/src/keypairUtils.ts

Though, I am about to add a new PR soon to fix the key derivation for Solana today.

@PedroRosalba
Copy link
Author

What do you mean by "retrieve the wallet"?

Honestly I don't understand really well what this keypairUtils is doing. What is the function of this file in the plugin?

Sorry it's just that I need to understand these things better to implement. Also, can you give some explanation on how to do testing on the plugin?

@PedroRosalba
Copy link
Author

See if makes sense now? Also just for a quick clarification, to request the changes to go to develop branch, I need to open a brand new pull request right?

Copy link
Contributor

@JoeyKhd JoeyKhd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps use elizaLogger instead of console.log

great code btw

const stringParsed = uint8Parsed.toString();

const privateKey = starknet.starknetKeccak(stringParsed).toString();
const publicKey = starknet.ec.starkCurve.getStarkKey(privateKey);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, so I'm not familiar with Starknet, but could you walk me through this process. Everything looks good, but I wanna be able to document this as well so devs understand what is going on. Also, take a look at #2039 bc I made some changes to clarify the derive key functionality & you'll have to update a small part to the code.

@HashWarlock
Copy link
Collaborator

What do you mean by "retrieve the wallet"?

Honestly I don't understand really well what this keypairUtils is doing. What is the function of this file in the plugin?

Sorry it's just that I need to understand these things better to implement. Also, can you give some explanation on how to do testing on the plugin?

This is the doc on how to use the TEE Plugin currently. https://elizaos.github.io/eliza/docs/advanced/eliza-in-tee/
This has all you need to get started and test your solution live with the TEE Simulator then I can talk to you after on testing on real TEE Cloud

@HashWarlock HashWarlock changed the base branch from main to develop January 9, 2025 03:42
@PedroRosalba
Copy link
Author

pedrorosalba@pedrorosalba-TECRA-Z50-C:~/eliza$ git branch

  • develop
    main
    pedrorosalba@pedrorosalba-TECRA-Z50-C:~/eliza$ pnpm install --no-frozen-lockfile
    Scope: all 82 workspace projects
    packages/adapter-redis |  WARN  deprecated @types/ioredis@5.0.0
    packages/client-discord |  WARN  deprecated @discordjs/voice@0.17.0
    packages/client-slack |  WARN  deprecated @slack/events-api@3.0.1
    packages/core |  WARN  deprecated @types/pdfjs-dist@2.10.378
    packages/plugin-node |  WARN  deprecated @cliqz/adblocker-playwright@1.34.0
    packages/plugin-story |  WARN  deprecated @pinata/sdk@2.1.0
    packages/plugin-trustdb |  WARN  deprecated @types/dompurify@3.2.0
     WARN  37 deprecated subdependencies found: @cliqz/adblocker-content@1.34.0, @cliqz/adblocker-extended-selectors@1.34.0, @cliqz/adblocker@1.34.0, @confio/ics23@0.6.8, @humanwhocodes/config-array@0.13.0, @humanwhocodes/object-schema@2.0.3, @motionone/vue@10.16.4, @pythnetwork/price-service-client@1.9.0, @simplewebauthn/typescript-types@7.4.0, @substrate/connect@0.8.8, are-we-there-yet@2.0.0, are-we-there-yet@3.0.1, base-x@2.0.6, bin-version-check@6.0.0, cids@0.7.5, cids@0.8.3, core-js@2.6.12, domexception@4.0.0, eslint@8.57.1, gauge@3.0.2, gauge@4.0.4, glob@7.2.3, glob@8.1.0, har-validator@5.1.5, inflight@1.0.6, mkdirp@0.3.0, multiaddr@7.5.0, multibase@0.6.1, multibase@0.7.0, multibase@1.0.1, multicodec@1.0.4, npmlog@5.0.1, npmlog@6.0.2, puppeteer@19.11.1, request@2.88.2, rimraf@3.0.2, uuid@3.4.0
     WARN  Issues with peer dependencies found
    client
    └─┬ @react-spring/web 9.7.5
    ├── ✕ unmet peer react@"^16.8.0 || ^17.0.0 || ^18.0.0": found 19.0.0
    ├── ✕ unmet peer react-dom@"^16.8.0 || ^17.0.0 || ^18.0.0": found 19.0.0
    ├─┬ @react-spring/animated 9.7.5
    │ ├── ✕ unmet peer react@"^16.8.0 || ^17.0.0 || ^18.0.0": found 19.0.0
    │ └─┬ @react-spring/shared 9.7.5
    │ └── ✕ unmet peer react@"^16.8.0 || ^17.0.0 || ^18.0.0": found 19.0.0
    └─┬ @react-spring/core 9.7.5
    └── ✕ unmet peer react@"^16.8.0 || ^17.0.0 || ^18.0.0": found 19.0.0

docs
├─┬ typedoc 0.26.11
│ └── ✕ unmet peer typescript@"4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x || 5.6.x": found 5.7.3
└─┬ @docusaurus/preset-classic 3.6.3
└─┬ @docusaurus/theme-search-algolia 3.6.3
└─┬ @docsearch/react 3.8.2
└── ✕ unmet peer @types/react@">= 16.8.0 < 19.0.0": found 19.0.4

packages/client-lens
└─┬ @lens-protocol/client 2.2.0
└─┬ @lens-protocol/gated-content 0.5.1
└─┬ @lit-protocol/node-client 2.1.62
├─┬ @lit-protocol/auth-browser 2.1.62
│ └─┬ @walletconnect/ethereum-provider 2.17.3
│ └─┬ @walletconnect/modal 2.7.0
│ ├─┬ @walletconnect/modal-core 2.7.0
│ │ └─┬ valtio 1.11.2
│ │ ├── ✕ missing peer react@>=16.8
│ │ └─┬ use-sync-external-store 1.2.0
│ │ └── ✕ missing peer react@"^16.8.0 || ^17.0.0 || ^18.0.0"
│ └─┬ @walletconnect/modal-ui 2.7.0
│ └─┬ @walletconnect/modal-core 2.7.0
│ └── ✕ missing peer react@>=16.8
└─┬ @walletconnect/ethereum-provider 2.17.3
└── ✕ missing peer react@>=16.8
Peer dependencies that should be installed:
react@">=16.8.0 <17.0.0 || >=17.0.0 <18.0.0 || >=18.0.0 <19.0.0"

packages/core
├─┬ ai 3.4.33
│ └─┬ @ai-sdk/vue 0.0.59
│ └─┬ @ai-sdk/ui-utils 0.0.50
│ └─┬ zod-to-json-schema 3.24.1
│ └── ✕ unmet peer zod@^3.24.1: found 3.23.8
└─┬ @vitest/coverage-v8 2.1.5
└── ✕ unmet peer vitest@2.1.5: found 2.1.8

packages/plugin-0g
└─┬ @0glabs/0g-ts-sdk 0.2.1
└── ✕ unmet peer ethers@6.13.1: found 6.13.4

packages/plugin-flow
└─┬ @onflow/fcl 1.13.1
└─┬ @onflow/fcl-wc 5.5.1
└─┬ @walletconnect/modal 2.7.0
└─┬ @walletconnect/modal-core 2.7.0
└─┬ valtio 1.11.2
└─┬ use-sync-external-store 1.2.0
└── ✕ unmet peer react@"^16.8.0 || ^17.0.0 || ^18.0.0": found 19.0.0

packages/plugin-fuel
└─┬ fuels 0.97.2
└─┬ @fuel-ts/recipes 0.97.2
└─┬ @fuel-ts/utils 0.97.2
└── ✕ unmet peer vitest@~2.0.5: found 2.1.4

packages/plugin-goat
└─┬ @goat-sdk/adapter-vercel-ai 0.2.0
└── ✕ unmet peer ai@4.0.3: found 4.0.30

packages/plugin-rabbi-trader
├─┬ @goat-sdk/wallet-viem 0.1.3
│ └── ✕ unmet peer @goat-sdk/core@0.3.4: found 0.3.8
└─┬ @goat-sdk/plugin-coingecko 0.1.4
└── ✕ unmet peer @goat-sdk/core@0.3.14: found 0.3.8

packages/plugin-solana-agentkit
└─┬ solana-agent-kit 1.3.7
├─┬ @onsol/tldparser 0.6.7
│ ├── ✕ unmet peer borsh@^0.7.0: found 2.0.0
│ └── ✕ unmet peer buffer@6.0.1: found 6.0.3
└─┬ @tiplink/api 0.3.1
└─┬ @solana/spl-token 0.3.11
└─┬ @solana/spl-token-metadata 0.1.6
└─┬ @solana/codecs 2.0.0-rc.1
├── ✕ unmet peer typescript@>=5: found 4.9.5 in @tiplink/api
├─┬ @solana/codecs-core 2.0.0-rc.1
│ ├── ✕ unmet peer typescript@>=5: found 4.9.5 in @tiplink/api
│ └─┬ @solana/errors 2.0.0-rc.1
│ └── ✕ unmet peer typescript@>=5: found 4.9.5 in @tiplink/api
├─┬ @solana/codecs-numbers 2.0.0-rc.1
│ └── ✕ unmet peer typescript@>=5: found 4.9.5 in @tiplink/api
├─┬ @solana/codecs-strings 2.0.0-rc.1
│ └── ✕ unmet peer typescript@>=5: found 4.9.5 in @tiplink/api
├─┬ @solana/codecs-data-structures 2.0.0-rc.1
│ └── ✕ unmet peer typescript@>=5: found 4.9.5 in @tiplink/api
└─┬ @solana/options 2.0.0-rc.1
└── ✕ unmet peer typescript@>=5: found 4.9.5 in @tiplink/api

Packages: +1349 -544
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------------------
 ERR_PNPM_ENOTDIR  ENOTDIR: not a directory, rename '/home/pedrorosalba/eliza/client/node_modules/vite_tmp_23168' -> '/home/pedrorosalba/eliza/client/node_modules/vite'
Progress: resolved 4426, reused 1249, downloaded 0, added 140
pedrorosalba@pedrorosalba-TECRA-Z50-C:~/eliza$

hey! so...

I was trying to pnpm install the develop branch to test out my plugin but it is not working as you can see...

how can I test my plugins?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants